aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-cmd-var.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-01-30 13:56:56 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2015-01-30 13:56:56 -0500
commitca83fa81892ab61870295cb5397c59daff1a55e0 (patch)
treed29019a8622926923a68441ce64497cbacfb32dc /gdb/mi/mi-cmd-var.c
parentafa269ae41673cd5cc5f50d683a0f2d275a643e8 (diff)
downloadgdb-ca83fa81892ab61870295cb5397c59daff1a55e0.zip
gdb-ca83fa81892ab61870295cb5397c59daff1a55e0.tar.gz
gdb-ca83fa81892ab61870295cb5397c59daff1a55e0.tar.bz2
Free results of varobj_get_expression
varobj_get_expression returns an allocated string, which must be freed by the caller. gdb/ChangeLog: * mi-cmd-var.c (print_varobj): Free varobj_get_expression result. (mi_cmd_var_info_expression): Same. * varobj.c (varobj_get_expression): Mention in the comment that the result must by freed by the caller.
Diffstat (limited to 'gdb/mi/mi-cmd-var.c')
-rw-r--r--gdb/mi/mi-cmd-var.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index d873a17..d9b37f8 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -55,7 +55,12 @@ print_varobj (struct varobj *var, enum print_values print_values,
ui_out_field_string (uiout, "name", varobj_get_objname (var));
if (print_expression)
- ui_out_field_string (uiout, "exp", varobj_get_expression (var));
+ {
+ char *exp = varobj_get_expression (var);
+
+ ui_out_field_string (uiout, "exp", exp);
+ xfree (exp);
+ }
ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
if (mi_print_value_p (var, print_values))
@@ -485,6 +490,7 @@ mi_cmd_var_info_expression (char *command, char **argv, int argc)
struct ui_out *uiout = current_uiout;
const struct language_defn *lang;
struct varobj *var;
+ char *exp;
if (argc != 1)
error (_("-var-info-expression: Usage: NAME."));
@@ -495,7 +501,10 @@ mi_cmd_var_info_expression (char *command, char **argv, int argc)
lang = varobj_get_language (var);
ui_out_field_string (uiout, "lang", lang->la_natural_name);
- ui_out_field_string (uiout, "exp", varobj_get_expression (var));
+
+ exp = varobj_get_expression (var);
+ ui_out_field_string (uiout, "exp", exp);
+ xfree (exp);
}
void