polkit: Only unregister registered handles

If the initialization fails for some reason, for example by
running 'gnome-shell --replace', we should not crash because
of an attempt of unregistering an unregistered agent handle.

Fix that by checking if the handle is not NULL before calling
the unregistering routines.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/66
This commit is contained in:
Georges Basile Stavracas Neto 2018-03-22 11:11:38 -03:00
parent 72fa44d0fd
commit 127ba318fd
No known key found for this signature in database
GPG Key ID: 886C17EE170D1385

View File

@ -318,8 +318,11 @@ shell_polkit_authentication_agent_unregister (ShellPolkitAuthenticationAgent *ag
if (agent->current_request != NULL)
auth_request_dismiss (agent->current_request);
polkit_agent_listener_unregister (agent->handle);
agent->handle = NULL;
if (agent->handle)
{
polkit_agent_listener_unregister (agent->handle);
agent->handle = NULL;
}
}
static void maybe_process_next_request (ShellPolkitAuthenticationAgent *agent);