From: Andrew Burgess <aburgess@broadcom.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <gdb-patches@sourceware.org>, Andrew Burgess <aburgess@broadcom.com>
Subject: [PATCH] Delete temporary string within demangler even in failure cases.
Date: Tue, 27 May 2014 10:57:00 -0000 [thread overview]
Message-ID: <1401188253-15214-1-git-send-email-aburgess@broadcom.com> (raw)
Spotted that a call to demangle_template might allocate storage within a
temporary string even if the call to demangle_template eventually returns
failure.
This will never cause the demangler to crash, but does leak memory, as a
result I've not added any tests for this.
Calling string_delete is safe, even if nothing is allocated into the
string, the string is initialised with string_init, so we know the internal
pointers are NULL.
I don't have gcc write privilages, so if this is approved could someone
please commit for me.
Thanks,
Andrew
libiberty/ChangeLog
* cplus-dem.c (do_type): Call string_delete even if the call to
demangle_template fails.
---
libiberty/cplus-dem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index e948487..1c713aa 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -3656,7 +3656,10 @@ do_type (struct work_stuff *work, const char **mangled, string *result)
string_delete (&temp);
}
else
- break;
+ {
+ string_delete (&temp);
+ break;
+ }
}
else if (**mangled == 'Q')
{
--
1.8.1.3
next reply other threads:[~2014-05-27 10:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-27 10:57 Andrew Burgess [this message]
2014-05-27 13:47 ` Ian Lance Taylor
2014-06-10 18:08 ` Andrew Burgess
2014-06-11 11:02 ` Pedro Alves
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=1401188253-15214-1-git-send-email-aburgess@broadcom.com \
--to=aburgess@broadcom.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