libiconv VIQR: Fix a use after free.

Use TAILQ_FOREACH_SAFE to walk to list of children mnemonics to free
them instead of TAILQ_FOREACH.

Reviewed by:	emaste
Reported by:	GCC 12 -Wuse-after-free
Differential Revision:	https://reviews.freebsd.org/D36821
This commit is contained in:
John Baldwin 2022-10-03 16:10:43 -07:00
parent 7973f26ad6
commit 8f27c9d14a

View file

@ -195,9 +195,9 @@ mnemonic_append_child(mnemonic_t *m, const char *s,
static void
mnemonic_destroy(mnemonic_t *m)
{
mnemonic_t *m0;
mnemonic_t *m0, *n;
TAILQ_FOREACH(m0, &m->child, entry)
TAILQ_FOREACH_SAFE(m0, &m->child, entry, n)
mnemonic_destroy(m0);
free(m);
}