aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2010-12-02 20:05:59 +0000
committerKeith Seitz <keiths@redhat.com>2010-12-02 20:05:59 +0000
commitd03a3acf0710b16e2dc6fdf3ae4d9d0f794d3ab5 (patch)
tree4482117c9421de11b01ca9243bd3b013c88cd238 /gdb/linespec.c
parent989abc33c7ba48c2f91c2ac2668dcd7522cf997c (diff)
downloadfsf-binutils-gdb-d03a3acf0710b16e2dc6fdf3ae4d9d0f794d3ab5.zip
fsf-binutils-gdb-d03a3acf0710b16e2dc6fdf3ae4d9d0f794d3ab5.tar.gz
fsf-binutils-gdb-d03a3acf0710b16e2dc6fdf3ae4d9d0f794d3ab5.tar.bz2
* linespec.c (find_method): Move name canonicalization outside
the loop. Be paranoid and use a cleanup.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 91c5b90..7af0e3a 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1589,15 +1589,20 @@ find_method (int funfirstline, char ***canonical, char *saved_arg,
if (strchr (saved_arg, '(') != NULL)
{
int i;
+ char *name = saved_arg;
+ char *canon = cp_canonicalize_string (name);
+ struct cleanup *cleanup;
- for (i = 0; i < i1; ++i)
+ if (canon != NULL)
{
- char *name = saved_arg;
- char *canon = cp_canonicalize_string (name);
-
- if (canon != NULL)
- name = canon;
+ name = canon;
+ cleanup = make_cleanup (xfree, canon);
+ }
+ else
+ cleanup = make_cleanup (null_cleanup, NULL);
+ for (i = 0; i < i1; ++i)
+ {
if (strcmp_iw (name, SYMBOL_LINKAGE_NAME (sym_arr[i])) == 0)
{
values.sals = (struct symtab_and_line *)
@@ -1605,13 +1610,9 @@ find_method (int funfirstline, char ***canonical, char *saved_arg,
values.nelts = 1;
values.sals[0] = find_function_start_sal (sym_arr[i],
funfirstline);
- if (canon)
- xfree (canon);
+ do_cleanups (cleanup);
return values;
}
-
- if (canon)
- xfree (canon);
}
error (_("the class `%s' does not have any method instance named %s\n"),