diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-interp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 424264a..882384e 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -430,6 +430,14 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect, saved_output.file_to_delete = tee; } + /* Make sure that the call to logfile's dtor does not delete the + underlying pointer if we still keep a reference to it. If + logfile_p is not referenced as the file_to_delete, then either + the logfile is not used (no redirection) and it should be + deleted, or a tee took ownership of the pointer. */ + if (logfile_p != nullptr && saved_output.file_to_delete == logfile_p) + logfile.release (); + gdb_stdout = logging_redirect ? logfile_p : tee; gdb_stdlog = debug_redirect ? logfile_p : tee; gdb_stderr = logging_redirect ? logfile_p : tee; |