[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-9.1] util/log: add cleanup function
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH for-9.1] util/log: add cleanup function |
Date: |
Wed, 17 Apr 2024 21:33:33 +0300 |
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
- [PATCH for-9.1] util/log: add cleanup function,
Vladimir Sementsov-Ogievskiy <=