From b4f2035009192801a7dd02b3f6d6987d94ee3826 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 26 Jan 2004 14:58:50 +0000 Subject: make sure we pass \0 terminated string to eab_contact_list_from_string [it 2004-01-26 Radek Doulik * gui/widgets/e-addressbook-view.c (selection_received): make sure we pass \0 terminated string to eab_contact_list_from_string [it may fix #51743] svn path=/trunk/; revision=24435 --- addressbook/gui/widgets/e-addressbook-view.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'addressbook/gui/widgets/e-addressbook-view.c') diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index e3be750b07..633988ee31 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -1905,13 +1905,19 @@ selection_received (GtkWidget *invisible, guint time, EABView *view) { - if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { + if (selection_data->length <= 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { return; - } - else { - /* XXX make sure selection_data->data = \0 terminated */ - GList *contact_list = eab_contact_list_from_string (selection_data->data); + } else { + GList *contact_list; GList *l; + char *str = NULL; + + if (selection_data->data [selection_data->length - 1] != 0) { + str = g_malloc0 (selection_data->length + 1); + memcpy (str, selection_data->data, selection_data->length); + contact_list = eab_contact_list_from_string (str); + } else + contact_list = eab_contact_list_from_string (selection_data->data); for (l = contact_list; l; l = l->next) { EContact *contact = l->data; @@ -1922,6 +1928,7 @@ selection_received (GtkWidget *invisible, g_list_foreach (contact_list, (GFunc)g_object_unref, NULL); g_list_free (contact_list); + g_free (str); } } -- cgit v1.2.3