From ede74df828e2ff7232a8ee9589ed2061a673ddda Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 7 Jul 2015 18:30:11 +0100 Subject: [PATCH 2/4] xdg-cache: Ensure read_thumbnail_info() always sets an error on failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s GError convention to set the GError exactly when returning FALSE from a boolean-valued function. read_thumbnail_info() didn’t do that if libpng reported an error loading the PNG; fix that by returning TUMBLER_ERROR_INVALID_FORMAT in that case. https://bugzilla.xfce.org/show_bug.cgi?id=12036 --- plugins/xdg-cache/xdg-cache-cache.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/xdg-cache/xdg-cache-cache.c b/plugins/xdg-cache/xdg-cache-cache.c index f5c2a10..313cf8a 100644 --- a/plugins/xdg-cache/xdg-cache-cache.c +++ b/plugins/xdg-cache/xdg-cache-cache.c @@ -636,7 +636,9 @@ xdg_cache_cache_get_temp_file (const gchar *uri, } - +/* Will return %TRUE if the thumbnail was loaded successfully, or did not exist. + * Check whether @uri is non-%NULL and @mtime is a valid time to determine + * between the two. Will return %FALSE and set @error if the PNG was corrupt. */ gboolean xdg_cache_cache_read_thumbnail_info (const gchar *filename, gchar **uri, @@ -686,6 +688,11 @@ xdg_cache_cache_read_thumbnail_info (const gchar *filename, /* close the PNG file handle */ fclose (png); + /* Set an error. */ + g_set_error (error, TUMBLER_ERROR, + TUMBLER_ERROR_INVALID_FORMAT, + "Corrupt thumbnail PNG"); + return FALSE; } #endif -- 2.4.3