From 6d01627cd0278e951a4b4dd63ae060db8e7bb930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sun, 22 Oct 2023 22:59:10 +0200 Subject: [PATCH] wpctl: use auto cleanup for the `WpCtl` object This is already done for `WpDaemon` and `WpExec`, so let's do it here as well. This prevents some memory leaks in error paths, which makes it easier to find real issues in the ASan output. --- src/tools/wpctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/wpctl.c b/src/tools/wpctl.c index 9a8cd236..bb84bf24 100644 --- a/src/tools/wpctl.c +++ b/src/tools/wpctl.c @@ -86,6 +86,8 @@ wp_ctl_clear (WpCtl * self) g_clear_pointer (&self->context, g_option_context_free); } +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (WpCtl, wp_ctl_clear) + static void async_quit (WpCore *core, GAsyncResult *res, WpCtl * self) { @@ -1347,7 +1349,7 @@ on_plugin_loaded (WpCore * core, GAsyncResult * res, WpCtl *ctl) gint main (gint argc, gchar **argv) { - WpCtl ctl = {0}; + g_auto (WpCtl) ctl = {0}; const struct subcommand *cmd = NULL; g_autoptr (GError) error = NULL; g_autofree gchar *summary = NULL; @@ -1447,6 +1449,5 @@ main (gint argc, gchar **argv) g_main_loop_run (ctl.loop); - wp_ctl_clear (&ctl); return ctl.exit_code; }