From 28ef7456d3f219f6e4a7e655c78b9c547b8e16d1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 18 Oct 2017 15:24:03 +1000 Subject: [PATCH] util: add an extra assert for list_insert() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we're adding an element that's not null or not a freshly initialized list, chances are we haven't removed it from a previous list. Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ã…dahl --- src/libinput-util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libinput-util.c b/src/libinput-util.c index 48cb7181..93d73827 100644 --- a/src/libinput-util.c +++ b/src/libinput-util.c @@ -52,6 +52,8 @@ list_insert(struct list *list, struct list *elm) { assert((list->next != NULL && list->prev != NULL) || !"list->next|prev is NULL, possibly missing list_init()"); + assert(((elm->next == NULL && elm->prev == NULL) || list_empty(elm)) || + !"elm->next|prev is not NULL, list node used twice?"); elm->prev = list; elm->next = list->next;