mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-25 11:16:56 +08:00
Make cp_comp_to_string return a gdb::unique_xmalloc_ptr<char>
To help avoid issues like the one fixed by e88e8651cf34 ("Fix memory leak in cp-support.c"). gdb/ChangeLog: 2017-08-09 Pedro Alves <palves@redhat.com> * cp-name-parser.y (cp_comp_to_string): Return a gdb::unique_xmalloc_ptr<char>. * cp-support.c (replace_typedefs_qualified_name) (replace_typedefs): Adjust to use gdb::unique_xmalloc_ptr<char>. (cp_canonicalize_string_full): Use op= instead of explicit convertion. (cp_class_name_from_physname, method_name_from_physname) (cp_func_name, cp_remove_params): Adjust to use gdb::unique_xmalloc_ptr<char>. * cp-support.h (cp_comp_to_string): Return a gdb::unique_xmalloc_ptr<char>. * python/py-type.c (typy_lookup_type): Adjust to use gdb::unique_xmalloc_ptr<char>.
This commit is contained in:
@ -761,7 +761,6 @@ typy_lookup_type (struct demangle_component *demangled,
|
||||
const struct block *block)
|
||||
{
|
||||
struct type *type, *rtype = NULL;
|
||||
char *type_name = NULL;
|
||||
enum demangle_component_type demangled_type;
|
||||
|
||||
/* Save the type: typy_lookup_type() may (indirectly) overwrite
|
||||
@ -816,11 +815,8 @@ typy_lookup_type (struct demangle_component *demangled,
|
||||
return rtype;
|
||||
|
||||
/* We don't have a type, so lookup the type. */
|
||||
type_name = cp_comp_to_string (demangled, 10);
|
||||
type = typy_lookup_typename (type_name, block);
|
||||
xfree (type_name);
|
||||
|
||||
return type;
|
||||
gdb::unique_xmalloc_ptr<char> type_name = cp_comp_to_string (demangled, 10);
|
||||
return typy_lookup_typename (type_name.get (), block);
|
||||
}
|
||||
|
||||
/* This is a helper function for typy_template_argument that is used
|
||||
|
Reference in New Issue
Block a user