summaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2008-11-24 17:05:42 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2008-11-24 17:05:42 +0000
commit9cd2307aff9fc1ec8eef77b1082e5465efba9681 (patch)
treedbc89ca01c4aa7d822d5c5a9c4e83a2ed3f62a79 /gdb/parse.c
parent03b9244867f12755de6e9375fae71fbca961ca2e (diff)
downloadgdb-9cd2307aff9fc1ec8eef77b1082e5465efba9681.tar.gz
Fix access of an already freed memory.
* parse.c (parse_field_expression): Call xstrdup on `*name'. * completer.c (expression_completer): Free fieldname.
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 6200e8162fa..3575306d3b7 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);