From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
To: qemu-devel@nongnu.org
Cc: vsementsov@yandex-team.ru, pbonzini@redhat.com,
richard.henderson@linaro.org, stefanha@redhat.com,
groug@kaod.org
Subject: [PATCH for-9.1] util/log: add cleanup function
Date: Wed, 17 Apr 2024 21:33:33 +0300 [thread overview]
Message-ID: <20240417183333.39256-1-vsementsov@yandex-team.ru> (raw)
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
next reply other threads:[~2024-04-17 18:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 18:33 Vladimir Sementsov-Ogievskiy [this message]
2024-04-22 19:29 ` [PATCH for-9.1] util/log: add cleanup function Stefan Hajnoczi
2024-04-24 13:12 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240417183333.39256-1-vsementsov@yandex-team.ru \
--to=vsementsov@yandex-team.ru \
--cc=groug@kaod.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.