From d8466b6ccad33b6ded5c8b15f8742252247f7191 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 5 Mar 2023 17:06:30 +0900 Subject: [PATCH] [util] Fix a linked-list error in segtext Uncovered by the memory leak cleanup: the nodes were all being "linked" to the first node, those nodes in between the first and last were getting lost. --- libs/util/segtext.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/util/segtext.c b/libs/util/segtext.c index 812249811..a75a7c779 100644 --- a/libs/util/segtext.c +++ b/libs/util/segtext.c @@ -163,6 +163,7 @@ Segtext_new (const char *source_string) // If tags are duplicated, the first one takes precedence if ((*chunk)->tag && !Hash_Find (text->tab, (*chunk)->tag)) Hash_Add (text->tab, *chunk); + chunk = &(*chunk)->next; } return text; } @@ -177,8 +178,9 @@ Segtext_delete (segtext_t *st) while (st->chunk_list) { chunk = st->chunk_list; st->chunk_list = chunk->next; - if (chunk->tag) + if (chunk->tag) { free ((char *) chunk->tag); + } delete_chunk (chunk); } Hash_DelTable (st->tab);