aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/linkedlists.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk/linkedlists.h')
-rw-r--r--include/asterisk/linkedlists.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index 8e86470..4c9e27b 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -838,7 +838,10 @@ struct { \
*/
#define AST_LIST_REMOVE(head, elm, field) ({ \
__typeof(elm) __res = NULL; \
- if ((head)->first == (elm)) { \
+ __typeof(elm) __tmp = elm; \
+ if (!__tmp) { \
+ __res = NULL; \
+ } else if ((head)->first == (elm)) { \
__res = (head)->first; \
(head)->first = (elm)->field.next; \
if ((head)->last == (elm)) \
@@ -854,7 +857,9 @@ struct { \
(head)->last = curelm; \
} \
} \
- (elm)->field.next = NULL; \
+ if (__res) { \
+ (__res)->field.next = NULL; \
+ } \
(__res); \
})