After the loop ends, the iterator is not guaranteed to point to a valid object and should not be used. Make it NULL to avoid undefined behavior.
Signed-off-by: Adrian Moreno <[email protected]> --- include/openvswitch/list.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/openvswitch/list.h b/include/openvswitch/list.h index 263789b60..a63a51759 100644 --- a/include/openvswitch/list.h +++ b/include/openvswitch/list.h @@ -108,8 +108,9 @@ static inline bool ovs_list_is_short(const struct ovs_list *); UPDATE_MULTIVAR_SAFE(VAR)) #define LIST_FOR_EACH_POP(ITER, MEMBER, LIST) \ - while (!ovs_list_is_empty(LIST) \ - && (INIT_CONTAINER(ITER, ovs_list_pop_front(LIST), MEMBER), 1)) + while (!ovs_list_is_empty(LIST) ? \ + (INIT_CONTAINER(ITER, ovs_list_pop_front(LIST), MEMBER), 1) : \ + (ITER = NULL, 0)) /* Inline implementations. */ -- 2.34.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
