diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bfcfc748cc0..b12ce2a99cf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-03-25 Simon Marchi + + * source-cache.c (source_cache::get_source_lines): Re-read + fullname after calling open_source_file. + 2019-03-18 Pedro Alves Eli Zaretskii diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 9211f098eb7..5eae02082df 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -206,6 +206,12 @@ source_cache::get_source_lines (struct symtab *s, int first_line, if (desc.get () < 0) return false; find_source_lines (s, desc.get ()); + + /* FULLNAME points to a value owned by the symtab + (symtab::fullname). Calling open_source_file reallocates + that value, so we must refresh FULLNAME to avoid a + use-after-free. */ + fullname = symtab_to_fullname (s); } srchilite::SourceHighlight highlighter ("esc.outlang"); highlighter.setStyleFile("esc.style");