From 31402cb0068820b89488918d8bf78f8858d230b9 Mon Sep 17 00:00:00 2001 From: Lars Windolf Date: Mon, 23 Feb 2015 18:16:08 +0100 Subject: [PATCH] Github #145: Prevent segfault by not passing pixbuf on load error. Strip trailing slashes on feed URLs. --- ChangeLog | 2 ++ src/favicon.c | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a7793514..0970da1d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ To be released + * Fixes Github #154: Crashes while starting (corrupt icon) + (reported by jcamposz) * Github #149: Fixes a random crash on startup (patch by mozbugbox) * Fixes Github #79: RTL ordering of Back/Forward icons diff --git a/src/favicon.c b/src/favicon.c index 4d1ebc512..a16e3c0dc 100644 --- a/src/favicon.c +++ b/src/favicon.c @@ -77,25 +77,20 @@ favicon_load_from_cache (const gchar *id, guint size) GdkPixbuf *pixbuf, *result = NULL; GError *error = NULL; - debug_enter("favicon_load_from_cache"); - - /* try to load a saved favicon */ filename = common_create_cache_filename ("favicons", id, "png"); - if(0 == stat((const char*)filename, &statinfo)) { - pixbuf = gdk_pixbuf_new_from_file(filename, &error); - if(pixbuf) { - result = gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR); - g_object_unref(pixbuf); + if (0 == stat ((const char*)filename, &statinfo)) { + pixbuf = gdk_pixbuf_new_from_file (filename, &error); + if (pixbuf && !error) { + result = gdk_pixbuf_scale_simple (pixbuf, size, size, GDK_INTERP_BILINEAR); + g_object_unref (pixbuf); } else { /* Error */ - fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", + fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", filename, error->message); - g_error_free(error); + g_error_free (error); } } - g_free(filename); - - debug_exit("favicon_load_from_cache"); + g_free (filename); return result; } @@ -315,6 +310,10 @@ favicon_download (subscriptionPtr subscription, g_assert(source_url); if(*source_url != '|') { tmp = tmp2 = g_strstrip (g_strdup (source_url)); + + if(tmp[strlen(tmp) - 1] == '/') + tmp[strlen(tmp) - 1] = 0; /* Strip trailing slash */ + tmp = strrchr(tmp, '/'); if(tmp) { *tmp = 0;