From b1d8f84a9bff5bdb802f9344c3e445ea0643f496 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 21 Feb 2012 11:02:42 +0000 Subject: [PATCH] Account: don't crash on Get('Parameters') if _dup_parameters fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the connection manager is not installed, or is installed but doesn't have the protocol for the account, then _mcd_account_dup_parameters() returns %NULL. (As the comment I've added says, I think this is ridiculous—it's fall-out from MC not storing the types of parameters.) As a result, Get('Parameters') or GetAll() would crash, because dbus-glib would try to serialize a NULL GHashTable and blow up. (See .) So with this patch, we handle NULL as "no parameters" for the sake of D-Bus properties. (Because this situation should only arise if the account is invalid, we also warn if _dup_parameters() returns NULL for valid accounts.) --- src/mcd-account.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/src/mcd-account.c b/src/mcd-account.c index 36a86ce..9100e31 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -1396,6 +1396,15 @@ get_parameters (TpSvcDBusProperties *self, const gchar *name, McdAccount *account = MCD_ACCOUNT (self); GHashTable *params = _mcd_account_dup_parameters (account); + if (params == NULL) + { + if (mcd_account_is_valid (account)) + g_warning ("%s is supposedly valid, but _dup_parameters() failed!", + mcd_account_get_unique_name (account)); + + params = tp_asv_new (NULL, NULL); + } + g_value_init (value, TP_HASH_TYPE_STRING_VARIANT_MAP); g_value_take_boxed (value, params); } @@ -3227,6 +3236,14 @@ _mcd_account_dup_parameters (McdAccount *account) priv = account->priv; DEBUG ("called"); + + /* FIXME: this is ridiculous. MC stores the parameters for the account, so + * it should be able to expose them on D-Bus even if the CM is uninstalled. + * It shouldn't need to iterate across the parameters supported by the CM. + * But it does, because MC doesn't store the types of parameters. So it + * needs the CM (or .manager file) to be around to tell it whether "true" + * is a string or a boolean… + */ if (!priv->manager && !load_manager (account)) { DEBUG ("unable to load manager for account %s", priv->unique_name); -- 1.7.9