From cff99c75a889fa58cac70a08df8fbef08691121d Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 4 Oct 2024 14:00:47 +0200 Subject: [PATCH] Fix bug clearing field set --- src/field-set.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/field-set.h b/src/field-set.h index 4facab019..ef53f398d 100644 --- a/src/field-set.h +++ b/src/field-set.h @@ -148,14 +148,16 @@ gc_field_set_clear(struct gc_field_set *set, // wanted to it could re-add an edge to the remembered set. set->partly_full.list.head = NULL; set->full.head = NULL; - struct gc_edge_buffer *buf; - for (buf = partly_full; buf; buf = buf->next) { + struct gc_edge_buffer *buf, *next; + for (buf = partly_full; buf; buf = next) { + next = buf->next; for (size_t i = 0; i < buf->size; i++) forget_edge(buf->edges[i], heap); buf->size = 0; gc_edge_buffer_list_push(&set->empty, buf); } - for (buf = full; buf; buf = buf->next) { + for (buf = full; buf; buf = next) { + next = buf->next; for (size_t i = 0; i < buf->size; i++) forget_edge(buf->edges[i], heap); buf->size = 0;