BUG/MEDIUM: mt_lists: Make sure we set the deleted element to NULL;
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 10 Mar 2020 16:41:53 +0000 (17:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Mar 2020 14:52:57 +0000 (16:52 +0200)
In MT_LIST_DEL_SAFE(), when the code was changed to use a temporary variable
instead of using the provided pointer directly, we shouldn't have changed
the code that set the pointer to NULL, as we really want the pointer
provided to be nullified, otherwise other parts of the code won't know
we just deleted an element, and bad things will happen.

This should be backported to 2.1.

(cherry picked from commit 1d117e3dcdae6b59b19e0d875530b5d1f6b24c03)
Signed-off-by: Willy Tarreau <w@1wt.eu>

include/common/mini-clist.h

index 01bd0b6..f4d2e9f 100644 (file)
@@ -626,7 +626,7 @@ struct cond_wordlist {
                struct mt_list *el = (_el);                                \
                (el)->prev = (el);                                         \
                (el)->next = (el);                                         \
-               (el) = NULL;                                               \
+               (_el) = NULL;                                              \
        } while (0)
 
 /* Simpler FOREACH_ITEM_SAFE macro inspired from Linux sources.