Commit db5587c9 authored by Christian Kellner's avatar Christian Kellner
Browse files

Use g_autoptr in inhibitor lock code

Instead of doing manual memory management, use g_autoptr, because
it doing it manually is error prone.
Also use g_autoptr for the GError "error" and the GUnixFDList "fds"
which both were leaked before.
parent 28723742
Pipeline #27999 passed with stage
in 2 minutes and 53 seconds
......@@ -927,9 +927,10 @@ gbb_application_inhibitor_lock_release(GbbApplication *application)
static gboolean
gbb_application_inhibitor_lock_take(GbbApplication *application)
GVariant *out, *input;
GUnixFDList *fds;
GError *error = NULL;
g_autoptr(GVariant) out = NULL;
g_autoptr(GUnixFDList) fds = NULL;
g_autoptr(GError) error = NULL;
GVariant *input;
if (application->logind == NULL) {
return FALSE;
......@@ -961,12 +962,10 @@ gbb_application_inhibitor_lock_take(GbbApplication *application)
if (g_unix_fd_list_get_length (fds) != 1) {
g_warning ("Unexpected values returned by logind's 'Inhibit'");
g_variant_unref (out);
return FALSE;
application->inhibitor_fd = g_unix_fd_list_get (fds, 0, NULL);
g_variant_unref (out);
g_debug ("Acquired inhibitor lock (%i)", application->inhibitor_fd);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment