From 608e5eccf38ba0fbe113bfc47f08a051c3d1a9e3 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 14 Mar 2013 14:42:48 +0000 Subject: gdb/ * source.c (print_source_lines_base): Make a local copy of symtab_to_fullname. --- gdb/source.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'gdb/source.c') diff --git a/gdb/source.c b/gdb/source.c index b154dfe6177..2d9410ecc37 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1355,11 +1355,18 @@ print_source_lines_base (struct symtab *s, int line, int stopline, symtab_to_filename_for_display (s)); if (ui_out_is_mi_like_p (uiout) || !ui_out_test_flags (uiout, ui_source_list)) - { - const char *fullname = symtab_to_fullname (s); - - ui_out_field_string (uiout, "fullname", fullname); - } + { + const char *s_fullname = symtab_to_fullname (s); + char *local_fullname; + + /* ui_out_field_string may free S_FULLNAME by calling + open_source_file for it again. See e.g., + tui_field_string->tui_show_source. */ + local_fullname = alloca (strlen (s_fullname) + 1); + strcpy (local_fullname, s_fullname); + + ui_out_field_string (uiout, "fullname", local_fullname); + } ui_out_text (uiout, "\n"); } -- cgit v1.2.1