From 513e76aaf8ccbb86513d73e53595e63e390f87e6 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Tue, 4 Feb 2020 21:15:11 +0000 Subject: [PATCH] libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory. All callers pass a non-NULL pointer, and otherwise it was possible to leak memory if the abbrev was not added to a CU. CID: 1193365 MFC after: 1 week Sponsored by: The FreeBSD Foundation --- contrib/elftoolchain/libdwarf/libdwarf_abbrev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c b/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c index 9e4b6ab6108f..ff3a385f197f 100644 --- a/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c +++ b/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c @@ -59,9 +59,7 @@ _dwarf_abbrev_add(Dwarf_CU cu, uint64_t entry, uint64_t tag, uint8_t children, HASH_ADD(ab_hh, cu->cu_abbrev_hash, ab_entry, sizeof(ab->ab_entry), ab); - if (abp != NULL) - *abp = ab; - + *abp = ab; return (DW_DLE_NONE); }