Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: "dj@redhat.com" <dj@redhat.com>,
	 "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: libiberty/cplus-dem.c, ada-demangle: plug memory leak.
Date: Thu, 03 Mar 2011 21:20:00 -0000	[thread overview]
Message-ID: <4D70061C.10904@vmware.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 49 bytes --]

We don't have a separate libiberty list, do we?


[-- Attachment #2: cplus-dem.txt --]
[-- Type: text/plain, Size: 1026 bytes --]

2011-03-03  Michael Snyder  <msnyder@vmware.com>

	* libiberty/cplus-dem.c (ada_demangle): Stop memory leak.
	Also fix a one line indent problem.

Index: cplus-dem.c
===================================================================
RCS file: /cvs/src/src/libiberty/cplus-dem.c,v
retrieving revision 1.52
diff -u -p -u -p -r1.52 cplus-dem.c
--- cplus-dem.c	3 Jan 2011 21:05:58 -0000	1.52
+++ cplus-dem.c	3 Mar 2011 21:13:49 -0000
@@ -883,7 +883,7 @@ ada_demangle (const char *mangled, int o
   int len0;
   const char* p;
   char *d;
-  char *demangled;
+  char *demangled = NULL;
   
   /* Discard leading _ada_, which is used for library level subprograms.  */
   if (strncmp (mangled, "_ada_", 5) == 0)
@@ -1129,10 +1129,11 @@ ada_demangle (const char *mangled, int o
 
  unknown:
   len0 = strlen (mangled);
+  xfree (demangled);
   demangled = XNEWVEC (char, len0 + 3);
 
   if (mangled[0] == '<')
-     strcpy (demangled, mangled);
+    strcpy (demangled, mangled);
   else
     sprintf (demangled, "<%s>", mangled);
 

             reply	other threads:[~2011-03-03 21:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03 21:20 Michael Snyder [this message]
2011-03-03 21:30 ` Jakub Jelinek
2011-03-03 22:00   ` Michael Snyder
2011-03-04  9:34     ` Tristan Gingold
2011-03-04 18:07       ` Michael Snyder
     [not found]       ` <4D712A5F.1040307__35010.4677411311$1299262072$gmane$org@vmware.com>
2011-03-04 18:19         ` Tom Tromey
2011-03-04 18:27           ` Michael Snyder
     [not found]           ` <4D712F12.8050808__11842.7885965959$1299263268$gmane$org@vmware.com>
2011-03-04 18:37             ` Tom Tromey
2011-03-04 18:41               ` Jeff Law

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=4D70061C.10904@vmware.com \
    --to=msnyder@vmware.com \
    --cc=dj@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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