]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix linked lists tail (bug #951)
authorMark Spencer <markster@digium.com>
Thu, 29 Jan 2004 16:14:25 +0000 (16:14 +0000)
committerMark Spencer <markster@digium.com>
Thu, 29 Jan 2004 16:14:25 +0000 (16:14 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2090 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/linkedlists.h

index 30e09a0156bb20cd11929e7660df226d4d221a25..01067d5f07ee4dcba6e75a7d6a15cd0185f1bf0c 100755 (executable)
@@ -55,10 +55,14 @@ struct {                                                            \
 
 #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)