From 1d5037f725b691929396896fd2b6be3cae1d87ef Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 6 Feb 2013 13:15:10 +0100 Subject: backends: Check type DIE exists before calling dwarf_tag (). dwarf_attr () or dwarf_form () functions leave typedie NULL when they fail because of missing attribute or unexpected form. In such cases first check the DIE exists and return error instead of calling dwarf_tag () and crashing. This also happens in the testsuite with native tests when elfutils is build without DWZ support on a distro that uses DWZ DWARF compression on system libraries. Only the backends used dwarf_tag () directly without checking, all other uses in elfutils already checked whether the given DIE was NULL. Signed-off-by: Mark Wielaard --- backends/tilegx_retval.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backends/tilegx_retval.c') diff --git a/backends/tilegx_retval.c b/backends/tilegx_retval.c index fd4feef3..e14cc512 100644 --- a/backends/tilegx_retval.c +++ b/backends/tilegx_retval.c @@ -69,7 +69,7 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) Dwarf_Die die_mem; Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); - int tag = dwarf_tag (typedie); + int tag = DWARF_TAG_OR_RETURN (typedie); /* Follow typedefs and qualifiers to get to the actual type. */ while (tag == DW_TAG_typedef @@ -78,7 +78,7 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) { attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); typedie = dwarf_formref_die (attr, &die_mem); - tag = dwarf_tag (typedie); + tag = DWARF_TAG_OR_RETURN (typedie); } Dwarf_Word size; @@ -92,7 +92,7 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) { attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); typedie = dwarf_formref_die (attr, &die_mem); - tag = dwarf_tag (typedie); + tag = DWARF_TAG_OR_RETURN (typedie); } /* Fall through. */ @@ -142,7 +142,7 @@ tilegx_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) /* Check if it's a character array. */ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); typedie = dwarf_formref_die (attr, &die_mem); - tag = dwarf_tag (typedie); + tag = DWARF_TAG_OR_RETURN (typedie); if (tag != DW_TAG_base_type) goto aggregate; if (dwarf_formudata (dwarf_attr_integrate (typedie, -- cgit v1.2.3