Compare commits

...

4 Commits

Author SHA1 Message Date
Matthias Clasen
39f974358c Check error of g_dbus_proxy_new_sync call
Otherwise errors pile up and we crash later on.
2015-09-24 13:31:07 -04:00
Matthias Clasen
0fb98606ef shell_dbus_acquire_name: Don't leak the result
The GVariant returned by g_dbus_proxy_call_sync must be
freed with g_variant_unref, to prevent a leak.
2015-09-24 13:19:17 -04:00
Matthias Clasen
dd0d5a757c shell_dbus_acquire_name: Don't leak error
If fatal is not set, we return from this function in the error
case. Don't leak the GError if that happens.
2015-09-24 13:19:11 -04:00
Matthias Clasen
0bbb226faf shell_dbus_acquire_name: Don't assume error is set
In rare cases (mostly when the bus connection is going away),
g_dbus_proxy_call_sync can return NULL without setting an error.
Don't crash in this case.
2015-09-24 13:19:04 -04:00

View File

@ -68,12 +68,14 @@ shell_dbus_acquire_name (GDBusProxy *bus,
NULL, /* cancellable */
&error)))
{
g_printerr ("failed to acquire %s: %s\n", name, error->message);
g_printerr ("failed to acquire %s: %s\n", name, error ? error->message : "");
g_clear_error (&error);
if (!fatal)
return;
exit (1);
}
g_variant_get (request_name_variant, "(u)", request_name_result);
g_variant_unref (request_name_variant);
}
static void
@ -130,6 +132,12 @@ shell_dbus_init (gboolean replace)
NULL, /* cancellable */
&error);
if (!bus)
{
g_printerr ("Failed to get a session bus proxy: %s", error->message);
exit (1);
}
request_name_flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT;
if (replace)
request_name_flags |= DBUS_NAME_FLAG_REPLACE_EXISTING;