Merge branch 'gdbus-test-leak' into 'main'

tests: Fix a few minor leaks in gdbus-example-peer

See merge request GNOME/glib!3246
This commit is contained in:
Marco Trevisan 2023-02-01 16:24:57 +00:00
commit 151ca8d28d

View File

@ -147,7 +147,6 @@ on_new_connection (GDBusServer *server,
else else
s = g_credentials_to_string (credentials); s = g_credentials_to_string (credentials);
g_print ("Client connected.\n" g_print ("Client connected.\n"
"Peer credentials: %s\n" "Peer credentials: %s\n"
"Negotiated capabilities: unix-fd-passing=%d\n", "Negotiated capabilities: unix-fd-passing=%d\n",
@ -165,6 +164,8 @@ on_new_connection (GDBusServer *server,
NULL); /* GError** */ NULL); /* GError** */
g_assert (registration_id > 0); g_assert (registration_id > 0);
g_free (s);
return TRUE; return TRUE;
} }
@ -266,10 +267,14 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (opt_context, opt_entries, NULL); g_option_context_add_main_entries (opt_context, opt_entries, NULL);
if (!g_option_context_parse (opt_context, &argc, &argv, &error)) 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_printerr ("Error parsing options: %s\n", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
g_option_context_free (opt_context);
if (opt_address == NULL) if (opt_address == NULL)
{ {
g_printerr ("Incorrect usage, try --help.\n"); g_printerr ("Incorrect usage, try --help.\n");
@ -373,6 +378,8 @@ main (int argc, char *argv[])
-1, -1,
NULL, NULL,
&error); &error);
g_free (greeting);
if (value == NULL) if (value == NULL)
{ {
g_printerr ("Error invoking HelloWorld(): %s\n", error->message); g_printerr ("Error invoking HelloWorld(): %s\n", error->message);
@ -390,5 +397,7 @@ main (int argc, char *argv[])
ret = 0; ret = 0;
out: out:
g_free (opt_address);
return ret; return ret;
} }