[libbacktrace] Fix segfault upon allocation failure
authorTom de Vries <tdevries@suse.de>
Wed, 28 Nov 2018 14:06:23 +0000 (14:06 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Wed, 28 Nov 2018 14:06:23 +0000 (14:06 +0000)
commit18c742b5f0ae0285539e2dbea0c3a81961e9a7e5
treea0960c8ba093ba354d05ece895d0c38da1f36e6f
parent2bf8ae1b3d539eb7170eba9336d06b8383c3eba2
[libbacktrace] Fix segfault upon allocation failure

If the allocation of abbrevs->abbrevs in read_abbrevs fails, then
abbrevs->num_abbrevs remains nonzero, and consequently free_abbrevs will
segfault when accessing abbrevs->abbrevs.

Fix this by setting abbrevs->num_abbrevs only after abbrevs->abbrevs
allocation has succeeded.

Bootstrapped and reg-tested on x86_64.

2018-11-28  Tom de Vries  <tdevries@suse.de>

* dwarf.c (read_abbrevs): Fix handling of abbrevs->abbrevs allocation
failure.

From-SVN: r266562
libbacktrace/ChangeLog
libbacktrace/dwarf.c