+2019-01-10 Pedro Alves <palves@redhat.com>
+
+ * mdebugread.c (parse_partial_symbols): Use
+ gdb::unique_xmalloc_ptr to manage heap-allocated 'stabsstring'.
+
2019-01-10 Andrew Burgess <andrew.burgess@embecosm.com>
* linux-fork.c (scoped_switch_fork_info)
/* Handle stabs continuation. */
{
char *stabstring = debug_info->ss + fh->issBase + sh.iss;
+ /* If we need to heap-allocate STABSTRING, this owns
+ it. */
+ gdb::unique_xmalloc_ptr<char> stabstring_storage;
int len = strlen (stabstring);
while (stabstring[len - 1] == '\\')
stabstring2 = debug_info->ss + fh->issBase + sh2.iss;
len2 = strlen (stabstring2);
- /* Concatinate stabstring2 with stabstring1. */
- if (stabstring
- && stabstring != debug_info->ss + fh->issBase + sh.iss)
- stabstring
- = (char *) xrealloc (stabstring, len + len2 + 1);
+ /* Concatenate stabstring2 with stabstring1. */
+ if (stabstring_storage != nullptr)
+ {
+ stabstring_storage.reset
+ ((char *) xrealloc (stabstring_storage.release (),
+ len + len2 + 1));
+ stabstring = stabstring_storage.get ();
+ }
else
{
- stabstring = (char *) xmalloc (len + len2 + 1);
+ stabstring_storage.reset
+ ((char *) xmalloc (len + len2 + 1));
+ stabstring = stabstring_storage.get ();
strcpy (stabstring, stabstring1);
}
strcpy (stabstring + len, stabstring2);
hex_string (type_code)); /* CUR_SYMBOL_TYPE */
continue;
}
- if (stabstring
- && stabstring != debug_info->ss + fh->issBase + sh.iss)
- xfree (stabstring);
}
/* end - Handle continuation */
}