]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libasm: Fix use-after-free issue with circular single linked list cleanup
authorMark Wielaard <mark@klomp.org>
Fri, 17 Feb 2023 13:52:04 +0000 (14:52 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 21 Feb 2023 11:57:04 +0000 (12:57 +0100)
commiteb79a7bd87adc51dae77eb8d5ec37ad58ec71feb
tree60c0dfba1ba4edb4f6e2259e6ab7c2fa08ffafa1
parent77d237798c8f262d618bd3ed2db8864022bfcacb
libasm: Fix use-after-free issue with circular single linked list cleanup

Pointed out by gcc 12 with -Wuse-after-free=3

In function ‘free_section’
asm_end.c:552:17: error: pointer ‘data’ used after ‘free’ [-Werror=use-after-free]
  552 |     while (oldp != scnp->content);
      |            ~~~~~^~~~~~~~~~~~~~~~
asm_end.c:550:9: note: call to ‘free’ here
  550 |         free (oldp);
      |         ^~~~~~~~~~~

Fix by freeing scnp->content last.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libasm/ChangeLog
libasm/asm_end.c