[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.
This commit is contained in:
Bill Currie 2023-03-05 17:06:30 +09:00
parent 13f8f2b66b
commit d8466b6cca
1 changed files with 3 additions and 1 deletions

View File

@ -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);