aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-08-09 15:04:32 +0100
committerPedro Alves <palves@redhat.com>2017-08-09 15:04:32 +0100
commit29592bde87d250ea56e8431053918899d3d0c16b (patch)
tree6dc7c4b6f29dcf555f17d7ad1f931e44331e7334 /gdb/python
parentb33404388e5bbd8a1fddfde73cd4593ae2b557e8 (diff)
downloadgdb-29592bde87d250ea56e8431053918899d3d0c16b.zip
gdb-29592bde87d250ea56e8431053918899d3d0c16b.tar.gz
gdb-29592bde87d250ea56e8431053918899d3d0c16b.tar.bz2
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>.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-type.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index aa20d4c..51184ca 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -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