Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: dje@google.com (Doug Evans)
To: gdb-patches@sourceware.org
Subject: [commit] dwarf2read.c (typename_concat): avoid segv
Date: Fri, 24 Oct 2008 18:26:00 -0000	[thread overview]
Message-ID: <20081024182614.58B191C7947@localhost> (raw)

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


             reply	other threads:[~2008-10-24 18:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-24 18:26 Doug Evans [this message]
2008-10-24 18:43 ` Daniel Jacobowitz
2008-10-24 18:48   ` Daniel Jacobowitz
2008-10-24 18:57     ` Doug Evans
2008-10-24 19:01       ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081024182614.58B191C7947@localhost \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox