[empathy] Don't crash when the buffer has length 0



commit af1731d30620e7bd4aaa098af02adc3c71cb30f9
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Mon Nov 7 15:45:40 2011 +1100

    Don't crash when the buffer has length 0
    
    Unexpectedly, a 0 length buffer causes gdk_pixbuf_loader_write() to return
    FALSE without setting @error. Would then segv on error->message.

 libempathy-gtk/empathy-ui-utils.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 30b3e1f..5d9551d 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -491,7 +491,10 @@ empathy_pixbuf_from_avatar_scaled (EmpathyAvatar *avatar,
 			  G_CALLBACK (pixbuf_from_avatar_size_prepared_cb),
 			  &data);
 
-	if (!gdk_pixbuf_loader_write (loader, avatar->data, avatar->len, &error)) {
+	if (avatar->len == 0) {
+		g_warning ("Avatar has 0 length");
+		return NULL;
+	} else if (!gdk_pixbuf_loader_write (loader, avatar->data, avatar->len, &error)) {
 		g_warning ("Couldn't write avatar image:%p with "
 			   "length:%" G_GSIZE_FORMAT " to pixbuf loader: %s",
 			   avatar->data, avatar->len, error->message);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]