aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)