* 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.
This commit is contained in:
parent
09192bc76c
commit
1fcab1afa6
2 changed files with 56 additions and 19 deletions
|
@ -12,6 +12,12 @@
|
||||||
(tg_class_static_member): Likewise.
|
(tg_class_static_member): Likewise.
|
||||||
(tg_class_method_variant): Likewise.
|
(tg_class_method_variant): Likewise.
|
||||||
(tg_class_static_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>
|
2011-03-25 Pierre Muller <muller@ics.u-strasbg.fr>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* stabs.c -- Parse stabs debugging information
|
/* stabs.c -- Parse stabs debugging information
|
||||||
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
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>.
|
Written by Ian Lance Taylor <ian@cygnus.com>.
|
||||||
|
|
||||||
This file is part of GNU Binutils.
|
This file is part of GNU Binutils.
|
||||||
|
@ -1980,6 +1980,9 @@ parse_stab_enum_type (void *dhandle, const char **pp)
|
||||||
if (**pp != ',')
|
if (**pp != ',')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
|
free (name);
|
||||||
|
free (names);
|
||||||
|
free (values);
|
||||||
return DEBUG_TYPE_NULL;
|
return DEBUG_TYPE_NULL;
|
||||||
}
|
}
|
||||||
++*pp;
|
++*pp;
|
||||||
|
@ -2021,7 +2024,7 @@ parse_stab_struct_type (void *dhandle, struct stab_handle *info,
|
||||||
{
|
{
|
||||||
bfd_vma size;
|
bfd_vma size;
|
||||||
debug_baseclass *baseclasses;
|
debug_baseclass *baseclasses;
|
||||||
debug_field *fields;
|
debug_field *fields = NULL;
|
||||||
bfd_boolean statics;
|
bfd_boolean statics;
|
||||||
debug_method *methods;
|
debug_method *methods;
|
||||||
debug_type vptrbase;
|
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_members (dhandle, info, tagname, pp, typenums, &methods)
|
||||||
|| ! parse_stab_tilde_field (dhandle, info, pp, typenums, &vptrbase,
|
|| ! parse_stab_tilde_field (dhandle, info, pp, typenums, &vptrbase,
|
||||||
&ownvptr))
|
&ownvptr))
|
||||||
return DEBUG_TYPE_NULL;
|
{
|
||||||
|
if (fields != NULL)
|
||||||
|
free (fields);
|
||||||
|
return DEBUG_TYPE_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (! statics
|
if (! statics
|
||||||
&& baseclasses == NULL
|
&& baseclasses == NULL
|
||||||
|
@ -2240,7 +2247,10 @@ parse_stab_struct_fields (void *dhandle, struct stab_handle *info,
|
||||||
{
|
{
|
||||||
++*pp;
|
++*pp;
|
||||||
if (! parse_stab_cpp_abbrev (dhandle, info, pp, fields + c))
|
if (! parse_stab_cpp_abbrev (dhandle, info, pp, fields + c))
|
||||||
return FALSE;
|
{
|
||||||
|
free (fields);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
++c;
|
++c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2254,6 +2264,7 @@ parse_stab_struct_fields (void *dhandle, struct stab_handle *info,
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
|
free (fields);
|
||||||
return FALSE;
|
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,
|
type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
|
||||||
(debug_type **) NULL);
|
(debug_type **) NULL);
|
||||||
if (type == DEBUG_TYPE_NULL)
|
if (type == DEBUG_TYPE_NULL)
|
||||||
return FALSE;
|
{
|
||||||
|
free (name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (**pp == ':')
|
if (**pp == ':')
|
||||||
{
|
{
|
||||||
|
@ -2427,6 +2441,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
|
free (name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2444,6 +2459,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
|
||||||
if (**pp != ',')
|
if (**pp != ',')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
|
free (name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
++*pp;
|
++*pp;
|
||||||
|
@ -2452,6 +2468,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
|
||||||
if (**pp != ',')
|
if (**pp != ',')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
|
free (name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
++*pp;
|
++*pp;
|
||||||
|
@ -2460,6 +2477,7 @@ parse_stab_one_struct_field (void *dhandle, struct stab_handle *info,
|
||||||
if (**pp != ';')
|
if (**pp != ';')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
|
free (name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
++*pp;
|
++*pp;
|
||||||
|
@ -2511,6 +2529,9 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
debug_method *methods;
|
debug_method *methods;
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
unsigned int alloc;
|
unsigned int alloc;
|
||||||
|
char *name = NULL;
|
||||||
|
debug_method_variant *variants = NULL;
|
||||||
|
char *argtypes = NULL;
|
||||||
|
|
||||||
*retp = NULL;
|
*retp = NULL;
|
||||||
|
|
||||||
|
@ -2523,8 +2544,6 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
while (**pp != ';')
|
while (**pp != ';')
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
char *name;
|
|
||||||
debug_method_variant *variants;
|
|
||||||
unsigned int cvars;
|
unsigned int cvars;
|
||||||
unsigned int allocvars;
|
unsigned int allocvars;
|
||||||
debug_type look_ahead_type;
|
debug_type look_ahead_type;
|
||||||
|
@ -2553,7 +2572,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
if (*p != '.')
|
if (*p != '.')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
return FALSE;
|
goto fail;
|
||||||
}
|
}
|
||||||
name = savestring (*pp, p - *pp);
|
name = savestring (*pp, p - *pp);
|
||||||
*pp = p + 1;
|
*pp = p + 1;
|
||||||
|
@ -2570,7 +2589,6 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
{
|
{
|
||||||
debug_type type;
|
debug_type type;
|
||||||
bfd_boolean stub;
|
bfd_boolean stub;
|
||||||
char *argtypes;
|
|
||||||
enum debug_visibility visibility;
|
enum debug_visibility visibility;
|
||||||
bfd_boolean constp, volatilep, staticp;
|
bfd_boolean constp, volatilep, staticp;
|
||||||
bfd_vma voffset;
|
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,
|
type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
|
||||||
(debug_type **) NULL);
|
(debug_type **) NULL);
|
||||||
if (type == DEBUG_TYPE_NULL)
|
if (type == DEBUG_TYPE_NULL)
|
||||||
return FALSE;
|
goto fail;
|
||||||
|
|
||||||
if (**pp != ':')
|
if (**pp != ':')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
return FALSE;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2602,7 +2621,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
return FALSE;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
stub = FALSE;
|
stub = FALSE;
|
||||||
|
@ -2673,7 +2692,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
if (**pp != ';')
|
if (**pp != ';')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
return FALSE;
|
goto fail;
|
||||||
}
|
}
|
||||||
++*pp;
|
++*pp;
|
||||||
voffset &= 0x7fffffff;
|
voffset &= 0x7fffffff;
|
||||||
|
@ -2704,7 +2723,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
if (**pp != ';')
|
if (**pp != ';')
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
return FALSE;
|
goto fail;
|
||||||
}
|
}
|
||||||
++*pp;
|
++*pp;
|
||||||
}
|
}
|
||||||
|
@ -2747,18 +2766,18 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
|
|
||||||
class_type = stab_find_type (dhandle, info, typenums);
|
class_type = stab_find_type (dhandle, info, typenums);
|
||||||
if (class_type == DEBUG_TYPE_NULL)
|
if (class_type == DEBUG_TYPE_NULL)
|
||||||
return FALSE;
|
goto fail;
|
||||||
return_type = debug_get_return_type (dhandle, type);
|
return_type = debug_get_return_type (dhandle, type);
|
||||||
if (return_type == DEBUG_TYPE_NULL)
|
if (return_type == DEBUG_TYPE_NULL)
|
||||||
{
|
{
|
||||||
bad_stab (orig);
|
bad_stab (orig);
|
||||||
return FALSE;
|
goto fail;
|
||||||
}
|
}
|
||||||
type = parse_stab_argtypes (dhandle, info, class_type, name,
|
type = parse_stab_argtypes (dhandle, info, class_type, name,
|
||||||
tagname, return_type, argtypes,
|
tagname, return_type, argtypes,
|
||||||
constp, volatilep, &physname);
|
constp, volatilep, &physname);
|
||||||
if (type == DEBUG_TYPE_NULL)
|
if (type == DEBUG_TYPE_NULL)
|
||||||
return FALSE;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cvars + 1 >= allocvars)
|
if (cvars + 1 >= allocvars)
|
||||||
|
@ -2782,7 +2801,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
constp,
|
constp,
|
||||||
volatilep);
|
volatilep);
|
||||||
if (variants[cvars] == DEBUG_METHOD_VARIANT_NULL)
|
if (variants[cvars] == DEBUG_METHOD_VARIANT_NULL)
|
||||||
return FALSE;
|
goto fail;
|
||||||
|
|
||||||
++cvars;
|
++cvars;
|
||||||
}
|
}
|
||||||
|
@ -2811,6 +2830,15 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
|
||||||
*retp = methods;
|
*retp = methods;
|
||||||
|
|
||||||
return TRUE;
|
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
|
/* 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);
|
ft = debug_get_field_type (minfo->dhandle, *fields);
|
||||||
if (ft == NULL)
|
if (ft == NULL)
|
||||||
return FALSE;
|
{
|
||||||
|
free (name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
dn = debug_get_type_name (minfo->dhandle, ft);
|
dn = debug_get_type_name (minfo->dhandle, ft);
|
||||||
if (dn != NULL && strcmp (dn, name) == 0)
|
if (dn != NULL && strcmp (dn, name) == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue