From c9cbe29851d8e44c0cd433a14d53e70bb3e4de22 Mon Sep 17 00:00:00 2001 From: palves Date: Wed, 11 Jun 2014 10:57:27 +0000 Subject: Delete temporary string within demangler even in failure cases. 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. libiberty/ChangeLog * cplus-dem.c (do_type): Call string_delete even if the call to demangle_template fails. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211449 138bc75d-0d04-0410-961f-82ee72b054a4 --- libiberty/ChangeLog | 5 +++++ libiberty/cplus-dem.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 8390e4c7841..ddd96cce82a 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2014-06-11 Andrew Burgess + + * cplus-dem.c (do_type): Call string_delete even if the call to + demangle_template fails. + 2014-06-01 Ray Donnelly * pex-win32.c (argv_to_cmdline): Don't quote diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c index 2dd0a8a5c84..52767cc8fde 100644 --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -3663,7 +3663,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') { -- cgit v1.2.1