summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2006-04-04 05:53:48 +0000
committerMark Spencer <markster@digium.com>2006-04-04 05:53:48 +0000
commitf11fb652624802eaeb8f8539733d326b246c6aab (patch)
tree4f896ce49cdceef6b56518be0b36fbcdaf4e55f5
parentbf4b484e628aa28958991a2fcd3369b761f102de (diff)
Does nobody know how to write a linked list properly? I mean seriously!
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@17183 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--include/asterisk/linkedlists.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index 610f8085b..8bff72e3f 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -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)