diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 97c39d7bcde..209d0b6da6e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2017-08-09 Alex Lindsay + Yao Qi + + * cp-support.c (cp_canonicalize_string_full): Use + gdb::unique_xmalloc_ptr. + (cp_canonicalize_string): Likewise. + 2017-08-09 Yao Qi * features/Makefile (WHICH): Remove i386/ non-linux stuff. diff --git a/gdb/cp-support.c b/gdb/cp-support.c index df9a563508c..f6557ab310f 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -527,9 +527,11 @@ cp_canonicalize_string_full (const char *string, replace_typedefs (info.get (), info->tree, finder, data); /* Convert the tree back into a string. */ - ret = cp_comp_to_string (info->tree, estimated_len); - gdb_assert (!ret.empty ()); + gdb::unique_xmalloc_ptr us (cp_comp_to_string (info->tree, + estimated_len)); + gdb_assert (us); + ret = us.get (); /* Finally, compare the original string with the computed name, returning NULL if they are the same. */ if (ret == string) @@ -566,15 +568,18 @@ cp_canonicalize_string (const char *string) return std::string (); estimated_len = strlen (string) * 2; - std::string ret = cp_comp_to_string (info->tree, estimated_len); + gdb::unique_xmalloc_ptr us (cp_comp_to_string (info->tree, + estimated_len)); - if (ret.empty ()) + if (!us) { warning (_("internal error: string \"%s\" failed to be canonicalized"), string); return std::string (); } + std::string ret (us.get ()); + if (ret == string) return std::string ();