Index: include/asterisk/linkedlists.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/linkedlists.h,v retrieving revision 1.2 diff -u -r1.2 linkedlists.h --- include/asterisk/linkedlists.h 13 Aug 2003 15:25:16 -0000 1.2 +++ include/asterisk/linkedlists.h 29 Jan 2004 15:59:18 -0000 @@ -55,10 +55,14 @@ #define AST_LIST_INSERT_TAIL(head, elm, type, field) do { \ struct type *curelm = (head)->first; \ - while ( curelm->field.next!=NULL ) { \ - curelm=curelm->field.next; \ + if(!curelm) { \ + AST_LIST_INSERT_HEAD(head, elm, field); \ + } else { \ + while ( curelm->field.next!=NULL ) { \ + curelm=curelm->field.next; \ + } \ + AST_LIST_INSERT_AFTER(curelm,elm,field); \ } \ - AST_LIST_INSERT_AFTER(curelm,elm,field); \ } while (0)