__libdw_find_attr will return NULL and might not set code or form.
Only use code or form if the returned address is not NULL.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2014-11-23 Mark Wielaard <mjw@redhat.com>
+
+ * dwarf_attr.c (dwarf_attr): Check __libdw_find_attr return value.
+ * dwarf_hasattr.c (dwarf_hasattr): Likewise.
+ * dwarf_siblingof.c (dwarf_siblingof): Likewise.
+
2014-11-23 Mark Wielaard <mjw@redhat.com>
* dwarf_getabbrev.c (__libdw_getabbrev): Don't assert on bad DWARF.
/* Return specific DWARF attribute of a DIE.
- Copyright (C) 2003, 2005 Red Hat, Inc.
+ Copyright (C) 2003, 2005, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
/* Always fill in the CU information. */
result->cu = die->cu;
- return result->code == search_name ? result : NULL;
+ return result->valp != NULL && result->code == search_name ? result : NULL;
}
INTDEF(dwarf_attr)
/* Check whether given DIE has specific attribute.
- Copyright (C) 2003, 2005 Red Hat, Inc.
+ Copyright (C) 2003, 2005, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
/* Search for the attribute with the given name. */
unsigned int code;
- (void) __libdw_find_attr (die, search_name, &code, NULL);
+ unsigned char *addr = __libdw_find_attr (die, search_name, &code, NULL);
- return code == search_name;
+ return addr != NULL && code == search_name;
}
INTDEF (dwarf_hasattr)
/* Return sibling of given DIE.
- Copyright (C) 2003-2010 Red Hat, Inc.
+ Copyright (C) 2003-2010, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
/* Find the end of the DIE or the sibling attribute. */
addr = __libdw_find_attr (&this_die, DW_AT_sibling, &sibattr.code,
&sibattr.form);
- if (sibattr.code == DW_AT_sibling)
+ if (addr != NULL && sibattr.code == DW_AT_sibling)
{
Dwarf_Off offset;
sibattr.valp = addr;