[telepathy-haze/master] Don't crash if NULL is passed to _set_own_status.
Will Thompson
will.thompson at collabora.co.uk
Fri Mar 27 11:58:50 PDT 2009
Fixes fd.o #19894
---
src/connection-presence.c | 36 +++++++++++++++++-------------------
1 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/src/connection-presence.c b/src/connection-presence.c
index 2be90b3..a1bb8fb 100644
--- a/src/connection-presence.c
+++ b/src/connection-presence.c
@@ -22,6 +22,8 @@
#include "connection-presence.h"
#include "debug.h"
+#include <telepathy-glib/dbus.h>
+
static const TpPresenceStatusOptionalArgumentSpec arg_specs[] = {
{ "message", "s" },
{ NULL, NULL }
@@ -270,37 +272,33 @@ _set_own_status (GObject *obj,
{
HazeConnection *self = HAZE_CONNECTION (obj);
const char *status_id = NULL;
- GValue *message_v;
- char *message = NULL;
+ const gchar *message = NULL;
GList *attrs = NULL;
- if (status)
+ if (status != NULL)
+ {
status_id = _get_purple_status_id (self, status->index);
- if (!status_id)
- {
+ if (status->optional_arguments != NULL)
+ message = tp_asv_get_string (status->optional_arguments, "message");
+ }
+
+ if (status_id == NULL)
+ {
/* TODO: Is there a more sensible way to have a default? */
DEBUG ("defaulting to 'available' status");
status_id = "available";
- }
+ }
- if (status->optional_arguments)
- {
- message_v = g_hash_table_lookup (status->optional_arguments, "message");
- if (message_v)
- message = g_value_dup_string (message_v);
- }
-
- if (message)
- {
+ if (message != NULL)
+ {
attrs = g_list_append (attrs, "message");
- attrs = g_list_append (attrs, message);
- }
+ attrs = g_list_append (attrs, (gchar *) message);
+ }
purple_account_set_status_list (self->account, status_id, TRUE, attrs);
+
g_list_free (attrs);
- if (message)
- g_free (message);
return TRUE;
}
--
1.5.6.5
More information about the telepathy-commits
mailing list