From e4818ba5276510602ff5550a1e5a058fca51e9d4 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Tue, 4 Oct 2016 16:15:37 +0200 Subject: [PATCH] list: LIST_INSERT_BEFORE: update head if necessary (#4261) If the new item is inserted before the first item in the list, then the head must be updated as well. Add a test to the list unit test to check for this. --- src/basic/list.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/basic/list.h b/src/basic/list.h index 5962aa421..c3771a177 100644 --- a/src/basic/list.h +++ b/src/basic/list.h @@ -142,6 +142,8 @@ } else { \ if ((_b->name##_prev = _a->name##_prev)) \ _b->name##_prev->name##_next = _b; \ + else \ + *_head = _b; \ _b->name##_next = _a; \ _a->name##_prev = _b; \ } \ -- 2.30.2