]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Does nobody know how to write a linked list properly? I mean seriously!
authorMark Spencer <markster@digium.com>
Tue, 4 Apr 2006 05:53:48 +0000 (05:53 +0000)
committerMark Spencer <markster@digium.com>
Tue, 4 Apr 2006 05:53:48 +0000 (05:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@17183 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/linkedlists.h

index 610f8085b7b3d065a3f74955adff37e45559959b..8bff72e3fa3ed6a68c2325d90ad267a703888b85 100644 (file)
@@ -478,11 +478,13 @@ struct {                                                          \
                        (head)->last = NULL;                    \
        } else {                                                                \
                typeof(elm) curelm = (head)->first;                     \
-               while (curelm->field.next != (elm))                     \
+               while (curelm && (curelm->field.next != (elm)))                 \
                        curelm = curelm->field.next;                    \
-               curelm->field.next = (elm)->field.next;                 \
-               if ((head)->last == (elm))                              \
-                       (head)->last = curelm;                          \
+               if (curelm) { \
+                       curelm->field.next = (elm)->field.next;                 \
+                       if ((head)->last == (elm))                              \
+                               (head)->last = curelm;                          \
+               } \
        }                                                               \
 } while (0)