]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
addr2line: handle_address initialize scopes to NULL.
authorMark Wielaard <mjw@redhat.com>
Mon, 20 Jan 2014 12:49:48 +0000 (13:49 +0100)
committerMark Wielaard <mjw@redhat.com>
Fri, 24 Jan 2014 11:40:28 +0000 (12:40 +0100)
dwarf_getscopes returns the number of scope DIEs containing a PC address.
It returns -1 for errors or 0 if no scopes match PC. If dwarf_getscopes
returned 0, then scopes will not be allocated and handle_address might free
the uninitialized scopes pointer. Make sure it always has a defined value.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/addr2line.c

index 99b1156455f531cc9128a552318ea0f175d6893b..57be0bb34b1b31eca81b24655249474eb4f22c64 100644 (file)
@@ -1,3 +1,7 @@
+2014-01-20  Mark Wielaard  <mjw@redhat.com>
+
+       * addr2line.c (handle_address): Initialize scopes to NULL.
+
 2014-01-17  Roland McGrath  <roland@redhat.com>
 
        * strip.c (handle_elf): Check for bogus values in sh_link, sh_info,
index 0541fb686184bffbc0d7b3c92a5a5859e61d5ca0..50fc2b38c367e4fcf5c0f1309a79c372d9feb2f0 100644 (file)
@@ -642,7 +642,7 @@ handle_address (const char *string, Dwfl *dwfl)
       Dwarf_Addr bias = 0;
       Dwarf_Die *cudie = dwfl_module_addrdie (mod, addr, &bias);
 
-      Dwarf_Die *scopes;
+      Dwarf_Die *scopes = NULL;
       int nscopes = dwarf_getscopes (cudie, addr - bias, &scopes);
       if (nscopes < 0)
        return 1;