diff -r 3c90dfc35f06 -r fd6e191f3268 src/linked_list.c --- a/src/linked_list.c Sat Oct 12 19:34:19 2024 +0200 +++ b/src/linked_list.c Sat Oct 12 19:41:04 2024 +0200 @@ -776,11 +776,10 @@ // element destruction cx_invoke_destructor(list, n->payload); - // free the node + // free the node and advance + void *next = n->next; cxFree(list->collection.allocator, n); - - // next - n = n->next; + n = next; } } else { char *dest = targetbuf; @@ -792,11 +791,10 @@ // advance target buffer dest += list->collection.elem_size; - // free the node + // free the node and advance + void *next = n->next; cxFree(list->collection.allocator, n); - - // next - n = n->next; + n = next; } }