diff options
-rw-r--r-- | libiberty/ChangeLog | 16 | ||||
-rw-r--r-- | libiberty/cplus-dem.c | 31 |
2 files changed, 32 insertions, 15 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 46db196..29ecf9f 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,19 @@ +2003-02-13 Daniel Jacobowitz <drow@mvista.com> + + Fix PR c++/7612. + * cplus-dem.c (demangle_signature): Call string_delete. + Remove extra string_init. + (demangle_arm_hp_template): Call string_delete instead of + string_clear. Add missing string_delete call. + (demangle_qualified): Add missing string_delete call. + (do_type): Remove unused variable btype. Add missing string_delete + call. Call string_delete instead of string_clear. + (demangle_fund_type): Move variable btype inside of the switch + statement. Add missing string_delete call. + (do_arg): Call string_delete instead of string_clear. Remove extra + string_init. + (demangle_nested_args): Free work->previous_argument. + 2003-02-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * acconfig.h: New file. Add uintptr_t. diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c index f42d618..5eb26a3 100644 --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -1429,6 +1429,7 @@ demangle_signature (work, mangled, declp) { string_append (&s, SCOPE_STRING (work)); string_prepends (declp, &s); + string_delete (&s); } oldmangled = NULL; expect_func = 1; @@ -1508,7 +1509,6 @@ demangle_signature (work, mangled, declp) { /* Read the return type. */ string return_type; - string_init (&return_type); (*mangled)++; success = do_type (work, mangled, &return_type); @@ -2321,7 +2321,7 @@ demangle_arm_hp_template (work, mangled, n, declp) string_append (declp, "<"); while (1) { - string_clear (&arg); + string_delete (&arg); switch (**mangled) { case 'T': @@ -2378,7 +2378,7 @@ demangle_arm_hp_template (work, mangled, n, declp) string_append (declp, "<"); /* should do error checking here */ while (args < e) { - string_clear (&arg); + string_delete (&arg); /* Check for type or literal here */ switch (*args) @@ -2393,6 +2393,7 @@ demangle_arm_hp_template (work, mangled, n, declp) goto cfront_template_args_done; string_append (&arg, "("); string_appends (&arg, &type_str); + string_delete (&type_str); string_append (&arg, ")"); if (*args != 'L') goto cfront_template_args_done; @@ -3350,6 +3351,7 @@ demangle_qualified (work, mangled, result, isfuncname, append) } else { + string_delete (&last_name); success = do_type (work, mangled, &last_name); if (!success) break; @@ -3492,10 +3494,8 @@ do_type (work, mangled, result) string decl; const char *remembered_type; int type_quals; - string btype; type_kind_t tk = tk_none; - string_init (&btype); string_init (&decl); string_init (result); @@ -3613,6 +3613,7 @@ do_type (work, mangled, result) string temp; do_type (work, mangled, &temp); string_prepends (&decl, &temp); + string_delete (&temp); } else if (**mangled == 't') { @@ -3623,7 +3624,7 @@ do_type (work, mangled, result) if (success) { string_prependn (&decl, temp.b, temp.p - temp.b); - string_clear (&temp); + string_delete (&temp); } else break; @@ -3803,11 +3804,8 @@ demangle_fund_type (work, mangled, result) int success = 1; char buf[10]; unsigned int dec = 0; - string btype; type_kind_t tk = tk_integral; - string_init (&btype); - /* First pick off any type qualifiers. There can be more than one. */ while (!done) @@ -3979,8 +3977,11 @@ demangle_fund_type (work, mangled, result) } case 't': { + string btype; + string_init (&btype); success = demangle_template (work, mangled, &btype, 0, 1, 1); string_appends (result, &btype); + string_delete (&btype); break; } default: @@ -4182,12 +4183,9 @@ do_arg (work, mangled, result) do not want to add additional types to the back-referenceable type vector when processing a repeated type. */ if (work->previous_argument) - string_clear (work->previous_argument); + string_delete (work->previous_argument); else - { - work->previous_argument = (string*) xmalloc (sizeof (string)); - string_init (work->previous_argument); - } + work->previous_argument = (string*) xmalloc (sizeof (string)); if (!do_type (work, mangled, work->previous_argument)) return 0; @@ -4551,7 +4549,10 @@ demangle_nested_args (work, mangled, declp) /* Restore the previous_argument field. */ if (work->previous_argument) - string_delete (work->previous_argument); + { + string_delete (work->previous_argument); + free ((char *) work->previous_argument); + } work->previous_argument = saved_previous_argument; --work->forgetting_types; work->nrepeats = saved_nrepeats; |