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] Avoid segfault on missing directory table.


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

commit afa6c9abf2c12c8e6155d088ea45e5091ca79c57
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Fri May 8 12:43:39 2015 -0700

    Avoid segfault on missing directory table.
    
    2015-05-08  Yao Qi  <yao@codesourcery.com>
    	    Sandra Loosemore  <sandra@codesourcery.com>
    
    	gdb/
    	* dwarf2read.c (setup_type_unit_groups): Do NULL pointer check
    	to 'lh->include_dirs' before accessing to it.
    	(psymtab_include_file_name): Likewise.
    	(dwarf_decode_lines_1): Likewise.
    	(dwarf_decode_lines): Likewise.
    	(file_file_name): Likewise.

Diff:
---
 gdb/ChangeLog    | 10 ++++++++++
 gdb/dwarf2read.c | 13 +++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b7a29e6..1004e11 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2015-05-08  Yao Qi  <yao@codesourcery.com>
+	    Sandra Loosemore  <sandra@codesourcery.com>
+
+	* dwarf2read.c (setup_type_unit_groups): Do NULL pointer check
+	to 'lh->include_dirs' before accessing to it.
+	(psymtab_include_file_name): Likewise.
+	(dwarf_decode_lines_1): Likewise.
+	(dwarf_decode_lines): Likewise.
+	(file_file_name): Likewise.
+
 2015-05-08  Sandra Loosemore  <sandra@codesourcery.com>
 
 	* nios2-linux-tdep.c (NIOS2_SIGRETURN_TRAMP_ADDR): Define.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8d9a394..23a2521 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9320,7 +9320,7 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
 	  const char *dir = NULL;
 	  struct file_entry *fe = &lh->file_names[i];
 
-	  if (fe->dir_index)
+	  if (fe->dir_index && lh->include_dirs != NULL)
 	    dir = lh->include_dirs[fe->dir_index - 1];
 	  dwarf2_start_subfile (fe->name, dir);
 
@@ -17396,7 +17396,7 @@ psymtab_include_file_name (const struct line_header *lh, int file_index,
   char *copied_name = NULL;
   int file_is_pst;
 
-  if (fe.dir_index)
+  if (fe.dir_index && lh->include_dirs != NULL)
     dir_name = lh->include_dirs[fe.dir_index - 1];
 
   if (!IS_ABSOLUTE_PATH (include_name)
@@ -17595,7 +17595,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
           struct file_entry *fe = &lh->file_names[file - 1];
           const char *dir = NULL;
 
-          if (fe->dir_index)
+          if (fe->dir_index && lh->include_dirs != NULL)
             dir = lh->include_dirs[fe->dir_index - 1];
 
 	  dwarf2_start_subfile (fe->name, dir);
@@ -17815,7 +17815,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
                 else
                   {
                     fe = &lh->file_names[file - 1];
-                    if (fe->dir_index)
+                    if (fe->dir_index && lh->include_dirs != NULL)
                       dir = lh->include_dirs[fe->dir_index - 1];
                     if (!decode_for_pst_p)
                       {
@@ -17958,7 +17958,7 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
 	  struct file_entry *fe;
 
 	  fe = &lh->file_names[i];
-	  if (fe->dir_index)
+	  if (fe->dir_index && lh->include_dirs != NULL)
 	    dir = lh->include_dirs[fe->dir_index - 1];
 	  dwarf2_start_subfile (fe->name, dir);
 
@@ -20640,7 +20640,8 @@ file_file_name (int file, struct line_header *lh)
     {
       struct file_entry *fe = &lh->file_names[file - 1];
 
-      if (IS_ABSOLUTE_PATH (fe->name) || fe->dir_index == 0)
+      if (IS_ABSOLUTE_PATH (fe->name) || fe->dir_index == 0
+	  || lh->include_dirs == NULL)
         return xstrdup (fe->name);
       return concat (lh->include_dirs[fe->dir_index - 1], SLASH_STRING,
 		     fe->name, NULL);


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