gdb/fix-symread-crash.diff

29 lines
1.1 KiB
Diff

Index: gdb-6.8.50.20090302/gdb/symfile.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/symfile.c 2009-07-28 12:49:19.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/symfile.c 2009-07-28 13:44:06.000000000 +0200
@@ -2342,8 +2342,14 @@ find_separate_debug_file (struct objfile
gdb_assert (i >= 0 && IS_DIR_SEPARATOR (dir[i]));
dir[i+1] = '\0';
+ canon_name = lrealpath (dir);
+ i = strlen (dir);
+ if (canon_name
+ && strlen (canon_name) > i)
+ i = strlen (canon_name);
+
debugfile = xmalloc (strlen (debug_file_directory) + 1
- + strlen (dir)
+ + i /* MAX (strlen (canon_name), strlen (dir)) */
+ strlen (DEBUG_SUBDIRECTORY)
+ strlen ("/")
+ strlen (basename)
@@ -2376,7 +2382,6 @@ find_separate_debug_file (struct objfile
/* If the file is in the sysroot, try using its base path in the
global debugfile directory. */
- canon_name = lrealpath (dir);
if (canon_name
&& strncmp (canon_name, gdb_sysroot, strlen (gdb_sysroot)) == 0
&& IS_DIR_SEPARATOR (canon_name[strlen (gdb_sysroot)]))