Skip to content

Commit

Permalink
Fixes Github #154: Crashes while starting (on corrupt icon) (reported…
Browse files Browse the repository at this point in the history
… by jcamposz)
  • Loading branch information
lwindolf committed Feb 23, 2015
1 parent e339780 commit 2067d27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 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 (on corrupt icon)
(reported by jcamposz)
* Fixes Github #134: Broken default news feed.
(reported by pvdl)
* Fixes Github #122: Crashes at launch, "segmentation fault"
Expand Down
30 changes: 16 additions & 14 deletions src/favicon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file favicon.c Liferea favicon handling
*
* Copyright (C) 2004-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
* Copyright (C) 2015 Lars Windolf <lars.windolf@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -68,31 +69,28 @@ favicon_download_ctxt_free (faviconDownloadCtxtPtr ctxt)

static void favicon_download_run(faviconDownloadCtxtPtr ctxt);

GdkPixbuf * favicon_load_from_cache(const gchar *id) {
GdkPixbuf *
favicon_load_from_cache (const gchar *id, guint size)
{
struct stat statinfo;
gchar *filename;
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, 16, 16, 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 @@ -312,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 2067d27

Please sign in to comment.