# HG changeset patch # User Mike Becker # Date 1728754864 -7200 # Node ID fd6e191f32683369fcd5b5f41e50f625f613018c # Parent 3c90dfc35f06b4785df7ec2bca08b3263d523a93 fix invalid reads when removing linked list nodes 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; } }