Skip to content

Commit

Permalink
Github #145: Prevent segfault by not passing pixbuf on load error. St…
Browse files Browse the repository at this point in the history
…rip trailing slashes on feed URLs.
  • Loading branch information
lwindolf committed Feb 23, 2015
1 parent c47fe92 commit 31402cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 12 additions & 13 deletions src/favicon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 31402cb

Please sign in to comment.