aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2011-03-25 17:46:07 +0000
committerNick Clifton <nickc@redhat.com>2011-03-25 17:46:07 +0000
commit1fcab1afa6e3b72649b61021898bb974c588219a (patch)
tree77005a82f30c4fd30b71e9e2d1f8fc8f1f067ea8 /binutils
parent09192bc76cfb5b1a064137930f10d60e4e24d2fe (diff)
downloadgdb-1fcab1afa6e3b72649b61021898bb974c588219a.zip
gdb-1fcab1afa6e3b72649b61021898bb974c588219a.tar.gz
gdb-1fcab1afa6e3b72649b61021898bb974c588219a.tar.bz2
* stabs.c (parse_stab_enum_type): Fix memory leaks.
(parse_stab_struct_type): Ditto. (parse_stab_struct_fields): Ditto. (parse_stab_one_struct_field): Ditto. (parse_stab_members): Ditto. (stab_demangle_qualified): Ditto.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/stabs.c69
2 files changed, 56 insertions, 19 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 07cfa8a..4ee9ea9 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -12,6 +12,12 @@
(tg_class_static_member): Likewise.
(tg_class_method_variant): Likewise.
(tg_class_static_method_variant): Likewise.
+ * stabs.c (parse_stab_enum_type): Fix memory leaks.
+ (parse_stab_struct_type): Ditto.
+ (parse_stab_struct_fields): Ditto.
+ (parse_stab_one_struct_field): Ditto.
+ (parse_stab_members): Ditto.
+ (stab_demangle_qualified): Ditto.
2011-03-25 Pierre Muller <muller@ics.u-strasbg.fr>
diff --git a/binutils/stabs.c b/binutils/stabs.c
index f8fb48c..9534d66 100644
--- a/binutils/stabs.c
+++ b/binutils/stabs.c
@@ -1,6 +1,6 @@
/* stabs.c -- Parse stabs debugging information
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@cygnus.com>.
This file is part of GNU Binutils.
@@ -1980,6 +1980,9 @@ parse_stab_enum_type (void *dhandle, const char **pp)
if (**pp != ',')
{
bad_stab (orig);
+ free (name);
+ free (names);
+ free (values);
return DEBUG_TYPE_NULL;
}
++*pp;
@@ -2021,7 +2024,7 @@ parse_stab_struct_type (void *dhandle, struct stab_handle *info,
{
bfd_vma size;
debug_baseclass *baseclasses;
- debug_field *fields;
+ debug_field *fields = NULL;
bfd_boolean statics;
debug_method *methods;
debug_type vptrbase;
@@ -2036,7 +2039,11 @@ parse_stab_struct_type (void *dhandle, struct stab_handle *info,
|| ! parse_stab_members (dhandle, info, tagname, pp, typenums, &methods)
|| ! parse_stab_tilde_field (dhandle, info, pp, typenums, &vptrbase,
&ownvptr))
- return DEBUG_TYPE_NULL;
+ {
+ if (fields != NULL)
+ free (fields);
+ return DEBUG_TYPE_NULL;
+ }
if (! statics
&& baseclasses == NULL
@@ -2240,7 +2247,10 @@ parse_stab_struct_fields (void *dhandle, struct stab_handle *info,
{
++*pp;
if (! parse_stab_cpp_abbrev (dhandle, info, pp, fields + c))
- return FALSE;
+ {
+ free (fields);
+ return FALSE;
+ }
++c;
continue;
}
@@ -2254,6 +2264,7 @@ parse_stab_struct_fields (void *dhandle, struct stab_handle *info,
if (p == NULL)
{
bad_stab (orig);
+ free (fields);
return FALSE;
}
@@ -2415,7 +2426,10 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
(debug_type **) NULL);
if (type == DEBUG_TYPE_NULL)
- return FALSE;
+ {
+ free (name);
+ return FALSE;
+ }
if (**pp == ':')
{
@@ -2427,6 +2441,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
if (p == NULL)
{
bad_stab (orig);
+ free (name);
return FALSE;
}
@@ -2444,6 +2459,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
if (**pp != ',')
{
bad_stab (orig);
+ free (name);
return FALSE;
}
++*pp;
@@ -2452,6 +2468,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
if (**pp != ',')
{
bad_stab (orig);
+ free (name);
return FALSE;
}
++*pp;
@@ -2460,6 +2477,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
if (**pp != ';')
{
bad_stab (orig);
+ free (name);
return FALSE;
}
++*pp;
@@ -2511,6 +2529,9 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
debug_method *methods;
unsigned int c;
unsigned int alloc;
+ char *name = NULL;
+ debug_method_variant *variants = NULL;
+ char *argtypes = NULL;
*retp = NULL;
@@ -2523,8 +2544,6 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
while (**pp != ';')
{
const char *p;
- char *name;
- debug_method_variant *variants;
unsigned int cvars;
unsigned int allocvars;
debug_type look_ahead_type;
@@ -2553,7 +2572,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
if (*p != '.')
{
bad_stab (orig);
- return FALSE;
+ goto fail;
}
name = savestring (*pp, p - *pp);
*pp = p + 1;
@@ -2570,7 +2589,6 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
{
debug_type type;
bfd_boolean stub;
- char *argtypes;
enum debug_visibility visibility;
bfd_boolean constp, volatilep, staticp;
bfd_vma voffset;
@@ -2589,11 +2607,12 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
(debug_type **) NULL);
if (type == DEBUG_TYPE_NULL)
- return FALSE;
+ goto fail;
+
if (**pp != ':')
{
bad_stab (orig);
- return FALSE;
+ goto fail;
}
}
@@ -2602,7 +2621,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
if (p == NULL)
{
bad_stab (orig);
- return FALSE;
+ goto fail;
}
stub = FALSE;
@@ -2673,7 +2692,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
if (**pp != ';')
{
bad_stab (orig);
- return FALSE;
+ goto fail;
}
++*pp;
voffset &= 0x7fffffff;
@@ -2704,7 +2723,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
if (**pp != ';')
{
bad_stab (orig);
- return FALSE;
+ goto fail;
}
++*pp;
}
@@ -2747,18 +2766,18 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
class_type = stab_find_type (dhandle, info, typenums);
if (class_type == DEBUG_TYPE_NULL)
- return FALSE;
+ goto fail;
return_type = debug_get_return_type (dhandle, type);
if (return_type == DEBUG_TYPE_NULL)
{
bad_stab (orig);
- return FALSE;
+ goto fail;
}
type = parse_stab_argtypes (dhandle, info, class_type, name,
tagname, return_type, argtypes,
constp, volatilep, &physname);
if (type == DEBUG_TYPE_NULL)
- return FALSE;
+ goto fail;
}
if (cvars + 1 >= allocvars)
@@ -2782,7 +2801,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
constp,
volatilep);
if (variants[cvars] == DEBUG_METHOD_VARIANT_NULL)
- return FALSE;
+ goto fail;
++cvars;
}
@@ -2811,6 +2830,15 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
*retp = methods;
return TRUE;
+
+ fail:
+ if (name != NULL)
+ free (name);
+ if (variants != NULL)
+ free (variants);
+ if (argtypes != NULL)
+ free (argtypes);
+ return FALSE;
}
/* Parse a string representing argument types for a method. Stabs
@@ -4108,7 +4136,10 @@ stab_demangle_qualified (struct stab_demangle_info *minfo, const char **pp,
ft = debug_get_field_type (minfo->dhandle, *fields);
if (ft == NULL)
- return FALSE;
+ {
+ free (name);
+ return FALSE;
+ }
dn = debug_get_type_name (minfo->dhandle, ft);
if (dn != NULL && strcmp (dn, name) == 0)
{