This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB 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]

[binutils-gdb] (open_and_init_dwp_file): Protect against some segvs


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=08302ed2cb8b175e3bbd4308879154baf64e6d98

commit 08302ed2cb8b175e3bbd4308879154baf64e6d98
Author: Doug Evans <dje@google.com>
Date:   Thu Sep 28 09:20:59 2017 -0700

    (open_and_init_dwp_file): Protect against some segvs
    
    This is a "tiny patch", no assignment required.
    
    2017-09-28  Alexander Shaposhnikov <alexander.v.shaposhnikov@gmail.com>
    
    	* dwarf2read.c (open_and_init_dwp_file): Protect against dwp_file
    	having NULL cus or tus.

Diff:
---
 gdb/ChangeLog    |  5 +++++
 gdb/dwarf2read.c | 11 +++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f109ffe..2120df6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-28  Alexander Shaposhnikov <alexander.v.shaposhnikov@gmail.com> (tiny patch)
+
+	* dwarf2read.c (open_and_init_dwp_file): Protect against dwp_file
+	having NULL cus or tus.
+
 2017-09-27  Ulrich Weigand  <uweigand@de.ibm.com>
 
 	* arm-tdep.c: (convert_from_extended): Remove.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 7a59c1b..1b15adc 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11199,7 +11199,8 @@ open_and_init_dwp_file (void)
   dwp_file->tus = create_dwp_hash_table (dwp_file, 1);
 
   /* The DWP file version is stored in the hash table.  Oh well.  */
-  if (dwp_file->cus->version != dwp_file->tus->version)
+  if (dwp_file->cus && dwp_file->tus
+      && dwp_file->cus->version != dwp_file->tus->version)
     {
       /* Technically speaking, we should try to limp along, but this is
 	 pretty bizarre.  We use pulongest here because that's the established
@@ -11209,7 +11210,13 @@ open_and_init_dwp_file (void)
 	     pulongest (dwp_file->cus->version),
 	     pulongest (dwp_file->tus->version), dwp_name.c_str ());
     }
-  dwp_file->version = dwp_file->cus->version;
+
+  if (dwp_file->cus)
+    dwp_file->version = dwp_file->cus->version;
+  else if (dwp_file->tus)
+    dwp_file->version = dwp_file->tus->version;
+  else
+    dwp_file->version = 2;
 
   if (dwp_file->version == 2)
     bfd_map_over_sections (dwp_file->dbfd, dwarf2_locate_v2_dwp_sections,


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