From 5df8691aad188fdf540f10ad1de97d6c9b716bfe Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Mon, 2 Feb 2004 21:23:09 +0000 Subject: [PATCH] Return NULL if image length is zero. (photo_setter): Warn and don't set 2004-02-02 Hans Petter Jansson * libebook/e-contact.c (photo_getter): Return NULL if image length is zero. (photo_setter): Warn and don't set photo if image length is zero. --- addressbook/ChangeLog | 6 ++++++ addressbook/libebook/e-contact.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 18a2a13..6e3dbf7 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,5 +1,11 @@ 2004-02-02 Hans Petter Jansson + * libebook/e-contact.c (photo_getter): Return NULL if image length is + zero. + (photo_setter): Warn and don't set photo if image length is zero. + +2004-02-02 Hans Petter Jansson + * libebook/e-contact.c (photo_setter): Handle NULL. (fn_setter): Handle NULL. (n_setter): Handle NULL. diff --git a/addressbook/libebook/e-contact.c b/addressbook/libebook/e-contact.c index 19c05d0..a30a6b4 100644 --- a/addressbook/libebook/e-contact.c +++ b/addressbook/libebook/e-contact.c @@ -361,8 +361,12 @@ photo_getter (EContact *contact, EVCardAttribute *attr) if (values && values->data) { GString *s = values->data; - EContactPhoto *photo = g_new (EContactPhoto, 1); + EContactPhoto *photo; + if (!s->len) + return NULL; + + photo = g_new (EContactPhoto, 1); photo->length = s->len; photo->data = g_malloc (photo->length); memcpy (photo->data, s->str, photo->length); @@ -384,6 +388,8 @@ photo_setter (EContact *contact, EVCardAttribute *attr, void *data) if (!photo) return; + g_return_if_fail (photo->length > 0); + e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_ENCODING), "b"); -- 2.7.4