qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-9.1] util/log: add cleanup function
@ 2024-04-17 18:33 Vladimir Sementsov-Ogievskiy
  2024-04-22 19:29 ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-04-17 18:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: vsementsov, pbonzini, richard.henderson, stefanha, groug

We leak global_filename, and do not close global_file. Let's fix that.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---

Interesting: seems, nobody is maintainer of util/log.c

 util/log.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/util/log.c b/util/log.c
index d36c98da0b..30de209210 100644
--- a/util/log.c
+++ b/util/log.c
@@ -85,6 +85,15 @@ static void qemu_log_thread_cleanup(Notifier *n, void *unused)
     }
 }
 
+static void __attribute__((__destructor__)) cleanup(void)
+{
+    g_free(global_filename);
+    if (global_file && global_file != stderr) {
+        fclose(global_file);
+        global_file = NULL;
+    }
+}
+
 /* Lock/unlock output. */
 
 static FILE *qemu_log_trylock_with_err(Error **errp)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-24 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-17 18:33 [PATCH for-9.1] util/log: add cleanup function Vladimir Sementsov-Ogievskiy
2024-04-22 19:29 ` Stefan Hajnoczi
2024-04-24 13:12   ` Vladimir Sementsov-Ogievskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).