summaryrefslogtreecommitdiffstats
path: root/libdw
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-06-12 12:18:31 +0200
committerMark Wielaard <mark@klomp.org>2018-06-17 00:52:07 +0200
commit29a3395004643c4e412a47cec5de10f63c23f13c (patch)
treec4f602638416cabaf626f8d1905b7418d16cbc3a /libdw
parent6fbded3b73a1050e1efa410fc28a41fde29ed221 (diff)
libdw: Make __libdw_dieabbrev more robust on failure.
Make sure to always set die->abbrev to DWARF_END_ABBREV on failure. DWARF_END_ABBREV is also what the function reports on failure. And it will prevent trying to lookup the abbrev ever again. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/libdwP.h5
2 files changed, 8 insertions, 2 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 07a1346b..78321654 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-12 Mark Wielaard <mark@klomp.org>
+
+ * libdw.h (__libdw_dieabbrev): Set die->abbrev to DWARF_END_ABBREV
+ on failure.
+
2018-06-10 Mark Wielaard <mark@klomp.org>
* dwarf_attr_integrate.c (dwarf_attr_integrate): Stop after 16 DIE
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 3d8e145a..eebb7d12 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -653,8 +653,9 @@ __libdw_dieabbrev (Dwarf_Die *die, const unsigned char **readp)
/* Get the abbreviation code. */
unsigned int code;
const unsigned char *addr = die->addr;
- if (die->cu == NULL || addr >= (const unsigned char *) die->cu->endp)
- return DWARF_END_ABBREV;
+ if (unlikely (die->cu == NULL
+ || addr >= (const unsigned char *) die->cu->endp))
+ return die->abbrev = DWARF_END_ABBREV;
get_uleb128 (code, addr, die->cu->endp);
if (readp != NULL)
*readp = addr;