diff options
author | rbuj <[email protected]> | 2020-03-06 22:35:33 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-03-08 01:27:49 +0100 |
commit | 9f3d2d0986a6130b1cefc84caae161d75b4f56ba (patch) | |
tree | 59e0e3cfeae373ae9f041af128cc2005963451fa /src/gpm-manager.c | |
parent | a270eaa5178246c183ef8e681229b25dc8aff0d2 (diff) | |
download | mate-power-manager-9f3d2d0986a6130b1cefc84caae161d75b4f56ba.tar.bz2 mate-power-manager-9f3d2d0986a6130b1cefc84caae161d75b4f56ba.tar.xz |
gpm-manager: Remove dereference of a null pointer warning
Diffstat (limited to 'src/gpm-manager.c')
-rw-r--r-- | src/gpm-manager.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/gpm-manager.c b/src/gpm-manager.c index 68330aa..0c85d78 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -1756,7 +1756,7 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) { g_error_free (error); return -1; } - res = g_dbus_proxy_call_with_unix_fd_list_sync (proxy, "Inhibit", + res = g_dbus_proxy_call_with_unix_fd_list_sync (proxy, "Inhibit", g_variant_new( "(ssss)", arg_what, arg_who, @@ -1770,22 +1770,26 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) { NULL, &error ); - if (error == NULL && res != NULL) { - g_variant_get(res, "(h)", &r); - egg_debug ("Inhibiting systemd sleep res = %i", r); - fd = g_unix_fd_list_get (fd_list, r, &error); - if (fd == -1) { - egg_debug("Failed to get systemd inhibitor"); - return r; - } - egg_debug ("System inhibitor fd is %d", fd); - g_object_unref (fd_list); - g_variant_unref (res); - } else if (error != NULL || res == NULL) { + if (error != NULL) { egg_error ("Error in dbus - %s", error->message); g_error_free (error); return -EIO; } + if (res == NULL) + return -EIO; + + g_variant_get(res, "(h)", &r); + egg_debug ("Inhibiting systemd sleep res = %i", r); + + fd = g_unix_fd_list_get (fd_list, r, &error); + if (fd == -1) { + egg_debug("Failed to get systemd inhibitor"); + return r; + } + + egg_debug ("System inhibitor fd is %d", fd); + g_object_unref (fd_list); + g_variant_unref (res); egg_debug ("Inhibiting systemd sleep - success"); return r; } |