Delete temporary string within demangler even in failure cases.
authorAndrew Burgess <aburgess@broadcom.com>
Tue, 27 May 2014 10:57:33 +0000 (11:57 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 11 Jun 2014 10:41:51 +0000 (11:41 +0100)
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.

libiberty/ChangeLog
libiberty/cplus-dem.c

index 8390e4c784154bb823b6eb20451e4bfb57915c2b..ddd96cce82a267204910e94224966e9fa4626118 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-11  Andrew Burgess  <aburgess@broadcom.com>
+
+       * cplus-dem.c (do_type): Call string_delete even if the call to
+       demangle_template fails.
+
 2014-06-01  Ray Donnelly  <mingw.android@gmail.com>
 
        * pex-win32.c (argv_to_cmdline): Don't quote
index 2dd0a8a5c8451e22852f91afdc221579e91b780e..52767cc8fde1254d1c6bca78ee4aa7e6589975f6 100644 (file)
@@ -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')
              {
This page took 0.030141 seconds and 4 git commands to generate.