This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] addr2line: handle_address initialize scopes to NULL.


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   |    4 ++++
 src/addr2line.c |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 99b1156..57be0bb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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,
diff --git a/src/addr2line.c b/src/addr2line.c
index 0541fb6..50fc2b3 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -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;
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]