This is the mail archive of the gdb-patches@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]

[commit] dwarf2read.c (typename_concat): avoid segv


Hi. I checked in the following as obvious.
Running a large app with many shared libs under gdb -r caused gdb to segv.

2008-10-24  Doug Evans  <dje@google.com>

	* dwarf2read.c (typename_concat): Don't segv if prefix or suffix
	is NULL.  Simplify obs == NULL case.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.289
diff -u -p -r1.289 dwarf2read.c
--- dwarf2read.c	10 Oct 2008 16:15:42 -0000	1.289
+++ dwarf2read.c	24 Oct 2008 18:12:01 -0000
@@ -8081,19 +8081,17 @@ typename_concat (struct obstack *obs, co
   else
     sep = "::";
 
+  if (prefix == NULL)
+    prefix = "";
+  if (suffix == NULL)
+    suffix = "";
+
   if (obs == NULL)
     {
       char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
-      retval[0] = '\0';
-      
-      if (prefix)
-	{
-	  strcpy (retval, prefix);
-	  strcat (retval, sep);
-	}
-      if (suffix)
-	strcat (retval, suffix);
-      
+      strcpy (retval, prefix);
+      strcat (retval, sep);
+      strcat (retval, suffix);
       return retval;
     }
   else


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