aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-01-30 13:54:50 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2015-01-30 13:54:50 -0500
commitafa269ae41673cd5cc5f50d683a0f2d275a643e8 (patch)
treecd6896ed98d9a264c3bcc8f97aefd8bc3504fc40 /gdb/mi
parent9fc1d6863b1f46fd639afc3dfbe0b4c6d809ac05 (diff)
downloadgdb-afa269ae41673cd5cc5f50d683a0f2d275a643e8.zip
gdb-afa269ae41673cd5cc5f50d683a0f2d275a643e8.tar.gz
gdb-afa269ae41673cd5cc5f50d683a0f2d275a643e8.tar.bz2
Free results of varobj_get_type and type_to_string
varobj_get_type and type_to_string return an allocated string, which is not freed at a couple of places. New in v2: * Rename char * type to type_name. * Free in all cases in update_type_if_necessary. gdb/ChangeLog: * mi/mi-cmd-var.c (mi_cmd_var_info_type): Free result of varobj_get_type. (varobj_update_one): Same. * varobj.c (update_type_if_necessary): Free curr_type_str and new_type_str. (varobj_get_type): Specify in comment that the result needs to be freed by the caller.
Diffstat (limited to 'gdb/mi')
-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 01838b1..d873a17 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -447,14 +447,18 @@ mi_cmd_var_info_type (char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
struct varobj *var;
+ char *type_name;
if (argc != 1)
error (_("-var-info-type: Usage: NAME."));
/* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[0]);
+ type_name = varobj_get_type (var);
- ui_out_field_string (uiout, "type", varobj_get_type (var));
+ ui_out_field_string (uiout, "type", type_name);
+
+ xfree (type_name);
}
void
@@ -765,7 +769,12 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
}
if (r->type_changed)
- ui_out_field_string (uiout, "new_type", varobj_get_type (r->varobj));
+ {
+ char *type_name = varobj_get_type (r->varobj);
+
+ ui_out_field_string (uiout, "new_type", type_name);
+ xfree (type_name);
+ }
if (r->type_changed || r->children_changed)
ui_out_field_int (uiout, "new_num_children",