From: Tom Tromey Date: Fri, 16 Jan 2026 16:17:50 +0000 (-0700) Subject: Fix leaks with timestamped_file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ae0cd570509ca8546592099a649c25ef108dea9;p=thirdparty%2Fbinutils-gdb.git Fix leaks with timestamped_file This changes timestamped_file to own the stream it wraps. This is done simply because it was appropriate for all the code using this class. Approved-By: Andrew Burgess --- diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 41704fc44d1..f673fbf36f6 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -940,7 +940,7 @@ tui_initialize_io (void) /* Let tui_stderr own ERR_OUT. */ tui_stderr = new logging_file (ui_file_up (err_out)); tui_stdlog = (new timestamped_file - (new logging_file (err_out, true))); + (std::make_unique> (err_out, true))); tui_out = new cli_ui_out (tui_stdout, 0); /* Using redirectable_stdout here is a hack. This should probably diff --git a/gdb/ui-file.h b/gdb/ui-file.h index 94897ff0b77..d5771635468 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -442,11 +442,11 @@ protected: /* A ui_file that optionally puts a timestamp at the start of each line of output. */ -class timestamped_file : public wrapped_file +class timestamped_file : public wrapped_file { public: - explicit timestamped_file (ui_file *stream) - : wrapped_file (stream) + explicit timestamped_file (ui_file_up stream) + : wrapped_file (std::move (stream)) { } diff --git a/gdb/ui.c b/gdb/ui.c index 9d71135bc36..c1fc92e4ee6 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -56,7 +56,7 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_) m_ui_stderr (new logging_file (std::make_unique (errstream))), m_ui_stdlog (new timestamped_file - (new logging_file + (std::make_unique> (std::make_unique (errstream), true))), m_ui_stdtarg (m_ui_stderr) {