[gnome-shell] shell-network-agent: don't crash if a request isn't found
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] shell-network-agent: don't crash if a request isn't found
- Date: Fri, 27 Apr 2012 19:48:01 +0000 (UTC)
commit 8befcb9bba310ba25ae4cbc07fa6866b9a47360e
Author: Dan Winship <danw gnome org>
Date: Thu Apr 26 17:08:38 2012 -0400
shell-network-agent: don't crash if a request isn't found
If a request isn't found in shell_network_agent_set_password() or
shell_network_agent_respond(), then g_return_if_fail() rather than
crashing. OTOH, if a request is not found in
shell_network_agent_cancel_get_secrets(), then just ignore it
silently, since that could legitimately happen.
https://bugzilla.gnome.org/show_bug.cgi?id=674961
src/shell-network-agent.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/shell-network-agent.c b/src/shell-network-agent.c
index 9640236..a667bfa 100644
--- a/src/shell-network-agent.c
+++ b/src/shell-network-agent.c
@@ -409,6 +409,7 @@ shell_network_agent_set_password (ShellNetworkAgent *self,
priv = self->priv;
request = g_hash_table_lookup (priv->requests, request_id);
+ g_return_if_fail (request != NULL);
if (!request->is_vpn)
{
@@ -438,6 +439,7 @@ shell_network_agent_respond (ShellNetworkAgent *self,
priv = self->priv;
request = g_hash_table_lookup (priv->requests, request_id);
+ g_return_if_fail (request != NULL);
if (response == SHELL_NETWORK_AGENT_USER_CANCELED)
{
@@ -491,10 +493,20 @@ shell_network_agent_cancel_get_secrets (NMSecretAgent *agent,
gchar *request_id = g_strdup_printf ("%s/%s", connection_path, setting_name);
ShellAgentRequest *request = g_hash_table_lookup (priv->requests, request_id);
+ GError *error;
- GError *error = g_error_new (NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_AGENT_CANCELED,
- "Canceled by NetworkManager");
+ if (!request)
+ {
+ /* We've already sent the result, but the caller cancelled the
+ * operation before receiving that result.
+ */
+ g_free (request_id);
+ return;
+ }
+
+ error = g_error_new (NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_AGENT_CANCELED,
+ "Canceled by NetworkManager");
request->callback (agent, request->connection, NULL, error, request->callback_data);
g_signal_emit (self, signals[SIGNAL_CANCEL_REQUEST], 0, request_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]