From bd5e57ef1787cb07754b5e796723050f5a604331 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 31 Jan 2023 11:35:01 +0000 Subject: [PATCH] tests: Fix a few minor leaks in gdbus-example-peer One leak spotted by the Coverity, the others found via valgrind. Signed-off-by: Philip Withnall Coverity CID: #1504322 --- gio/tests/gdbus-example-peer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gio/tests/gdbus-example-peer.c b/gio/tests/gdbus-example-peer.c index f57d36832..29b3c2a07 100755 --- a/gio/tests/gdbus-example-peer.c +++ b/gio/tests/gdbus-example-peer.c @@ -147,7 +147,6 @@ on_new_connection (GDBusServer *server, else s = g_credentials_to_string (credentials); - g_print ("Client connected.\n" "Peer credentials: %s\n" "Negotiated capabilities: unix-fd-passing=%d\n", @@ -165,6 +164,8 @@ on_new_connection (GDBusServer *server, NULL); /* GError** */ g_assert (registration_id > 0); + g_free (s); + return TRUE; } @@ -266,10 +267,14 @@ main (int argc, char *argv[]) g_option_context_add_main_entries (opt_context, opt_entries, NULL); if (!g_option_context_parse (opt_context, &argc, &argv, &error)) { + g_option_context_free (opt_context); g_printerr ("Error parsing options: %s\n", error->message); g_error_free (error); goto out; } + + g_option_context_free (opt_context); + if (opt_address == NULL) { g_printerr ("Incorrect usage, try --help.\n"); @@ -373,6 +378,8 @@ main (int argc, char *argv[]) -1, NULL, &error); + g_free (greeting); + if (value == NULL) { g_printerr ("Error invoking HelloWorld(): %s\n", error->message); @@ -390,5 +397,7 @@ main (int argc, char *argv[]) ret = 0; out: + g_free (opt_address); + return ret; }