This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[jankratochvil-misc] Fix a completer regression if you link gdbwith -lmcheck
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: archer at sourceware dot org
- Date: Sun, 23 Nov 2008 00:11:09 +0100
- Subject: [jankratochvil-misc] Fix a completer regression if you link gdbwith -lmcheck
Fix a regression if you link gdb with -lmcheck:
-PASS: gdb.base/completion.exp: complete 'p values[0].a'
-PASS: gdb.base/completion.exp: complete 'p values[0] . a'
-PASS: gdb.base/completion.exp: complete 'p &values[0] -> a'
-PASS: gdb.base/completion.exp: cd to ${srcdir}
+FAIL: gdb.base/completion.exp: (timeout) complete 'p values[0].a' 2
+FAIL: gdb.base/completion.exp: (timeout) complete 'p values[0] . a' 2
+FAIL: gdb.base/completion.exp: (timeout) complete 'p &values[0] -> a' 2
+FAIL: gdb.base/completion.exp: cd to ${srcdir}
2008-11-22 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix access of an already freed memory.
* parse.c (parse_field_expression): Call xstrdup on `*name'.
* completer.c (expression_completer): Free fieldname.
---
gdb/completer.c | 2 ++
gdb/parse.c | 6 +++++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/gdb/completer.c b/gdb/completer.c
index e7ee817..d109140 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -414,9 +414,11 @@ expression_completer (char *text, char *word)
add_struct_fields (type, &out, result, fieldname, flen);
result[out] = NULL;
+ xfree (fieldname);
return result;
}
}
+ xfree (fieldname);
/* Commands which complete on locations want to see the entire
argument. */
diff --git a/gdb/parse.c b/gdb/parse.c
index 6200e81..3575306 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -1090,7 +1090,8 @@ parse_expression (char *string)
/* Parse STRING as an expression. If parsing ends in the middle of a
field reference, return the type of the left-hand-side of the
reference; furthermore, if the parsing ends in the field name,
- return the field name in *NAME. In all other cases, return NULL. */
+ return the field name in *NAME. In all other cases, return NULL.
+ Returned non-NULL *NAME must be freed by the caller. */
struct type *
parse_field_expression (char *string, char **name)
@@ -1120,6 +1121,9 @@ parse_field_expression (char *string, char **name)
xfree (exp);
return NULL;
}
+ /* (*NAME) is a part of the EXP memory block freed below. */
+ *name = xstrdup (*name);
+
val = evaluate_subexpression_type (exp, subexp);
xfree (exp);
--
1.6.0.3