From 83fb773c9ffbe4b5bffd79442bac8d9490f6a93d Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Sun, 11 Feb 2024 17:52:17 +0100 Subject: [PATCH] Reset mid field when the list is empty to avoid assert() errors Patch from https://github.com/LudovicRousseau/PCSC/commit/8999ddfc04ecbf596af1eea6efb6ed3c49392089 --- simclist.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/simclist.c b/simclist.c index 1b8d3c8..e6c93b1 100755 --- a/simclist.c +++ b/simclist.c @@ -472,6 +472,9 @@ void *list_extract_at(list_t *restrict l, unsigned int pos) { list_drop_elem(l, tmp, pos); l->numels--; + if (0 == l->numels) + l->mid = NULL; + assert(list_repOk(l)); return data; @@ -555,6 +558,8 @@ int list_delete_at(list_t *restrict l, unsigned int pos) { l->numels--; + if (0 == l->numels) + l->mid = NULL; assert(list_repOk(l));