From fe1664d311ffd37316118351c35cd50c4d2f9bda Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 11 Nov 2020 02:18:04 -0700 Subject: [PATCH] list: fix LIF_LIST_FOREACH_SAFE() iteration on empty lists --- libifupdown/list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libifupdown/list.h b/libifupdown/list.h index 877354e..c029038 100644 --- a/libifupdown/list.h +++ b/libifupdown/list.h @@ -40,7 +40,7 @@ extern void lif_node_delete(struct lif_node *node, struct lif_list *list); for ((iter) = (head); (iter) != NULL; (iter) = (iter)->next) #define LIF_LIST_FOREACH_SAFE(iter, iter_next, head) \ - for ((iter) = (head), (iter_next) = (iter)->next; (iter) != NULL; (iter) = (iter_next), (iter_next) = (iter) != NULL ? (iter)->next : NULL) + for ((iter) = (head), (iter_next) = (iter) != NULL ? (iter)->next : NULL; (iter) != NULL; (iter) = (iter_next), (iter_next) = (iter) != NULL ? (iter)->next : NULL) #define LIF_LIST_FOREACH_REVERSE(iter, tail) \ for ((iter) = (tail); (iter) != NULL; (iter) = (iter)->prev)