summaryrefslogtreecommitdiff
path: root/elfutils/libdw/dwarf_tag.c
diff options
context:
space:
mode:
Diffstat (limited to 'elfutils/libdw/dwarf_tag.c')
-rw-r--r--elfutils/libdw/dwarf_tag.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/elfutils/libdw/dwarf_tag.c b/elfutils/libdw/dwarf_tag.c
index 15183d2d..fa8b384c 100644
--- a/elfutils/libdw/dwarf_tag.c
+++ b/elfutils/libdw/dwarf_tag.c
@@ -1,5 +1,5 @@
/* Return tag of given DIE.
- Copyright (C) 2003, 2004, 2005, 2006, 2008 Red Hat, Inc.
+ Copyright (C) 2003-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -61,6 +61,10 @@ __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
{
Dwarf_Abbrev *abb;
+ /* Abbreviation code can never have a value of 0. */
+ if (unlikely (code == 0))
+ return DWARF_END_ABBREV;
+
/* See whether the entry is already in the hash table. */
abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code, NULL);
if (abb == NULL)
@@ -86,6 +90,11 @@ __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
break;
}
+ /* This is our second (or third, etc.) call to __libdw_findabbrev
+ and the code is invalid. */
+ if (unlikely (abb == NULL))
+ abb = DWARF_END_ABBREV;
+
return abb;
}