diff options
Diffstat (limited to 'libdw/dwarf_getabbrev.c')
-rw-r--r-- | libdw/dwarf_getabbrev.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libdw/dwarf_getabbrev.c b/libdw/dwarf_getabbrev.c index 6a7e981b..13bee493 100644 --- a/libdw/dwarf_getabbrev.c +++ b/libdw/dwarf_getabbrev.c @@ -83,7 +83,7 @@ __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset, bool foundit = false; Dwarf_Abbrev *abb = NULL; if (cu == NULL - || (abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code, NULL)) == NULL) + || (abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code)) == NULL) { if (result == NULL) abb = libdw_typed_alloc (dbg, Dwarf_Abbrev); @@ -99,6 +99,8 @@ __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset, /* A duplicate abbrev code at a different offset, that should never happen. */ invalid: + if (! foundit) + libdw_typed_unalloc (dbg, Dwarf_Abbrev); __libdw_seterrno (DWARF_E_INVALID_DWARF); return NULL; } @@ -148,7 +150,13 @@ __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset, /* Add the entry to the hash table. */ if (cu != NULL && ! foundit) - (void) Dwarf_Abbrev_Hash_insert (&cu->abbrev_hash, abb->code, abb); + if (Dwarf_Abbrev_Hash_insert (&cu->abbrev_hash, abb->code, abb) == -1) + { + /* The entry was already in the table, remove the one we just + created and get the one already inserted. */ + libdw_typed_unalloc (dbg, Dwarf_Abbrev); + abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code); + } out: return abb; |