util/hash.c: fix use after free (not quite)

Dereference of 'h' after calling freeMagic(h)
Found while putting in cast.

Initially this is what was thought however....

freeMagic() has this one allocation to free latency, which is a matter
to resolve another day.
This commit is contained in:
Darryl L. Miles 2024-10-04 11:19:10 +01:00 committed by Tim Edwards
parent fadd2d98b4
commit bbc52ecd41
1 changed files with 2 additions and 1 deletions

View File

@ -692,9 +692,10 @@ HashKill(table)
for (hp = table->ht_table, hend = &hp[table->ht_size]; hp < hend; hp++)
for (h = *hp; h != NIL; h = h->h_next)
{
const void *p = h->h_key.h_ptr;
freeMagic((char *) h);
if (killFn)
(*killFn)(h->h_key.h_ptr);
(*killFn)((void *)p);
}
freeMagic((char *) table->ht_table);