diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-07-07 18:30:11 +0100 |
---|---|---|
committer | Gaël Bonithon <gael@xfce.org> | 2021-12-16 11:46:04 +0100 |
commit | ac978918f804bc6afbeccc12dca16a1bdf5d6653 (patch) | |
tree | 06679be55b474b6a9345a1eafc2cf4ae3ff2f18e /plugins | |
parent | 56496090dfd7d3f7cc2f2f778d5993a2df05d057 (diff) | |
download | tumbler-ac978918f804bc6afbeccc12dca16a1bdf5d6653.tar.gz |
xdg-cache: Ensure read_thumbnail_info() always sets an error on failure
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.
Related to #12.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/xdg-cache/xdg-cache-cache.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/xdg-cache/xdg-cache-cache.c b/plugins/xdg-cache/xdg-cache-cache.c index 15ef219..1a0c9b4 100644 --- a/plugins/xdg-cache/xdg-cache-cache.c +++ b/plugins/xdg-cache/xdg-cache-cache.c @@ -26,6 +26,7 @@ #include <string.h> #include <glib.h> +#include <glib/gi18n.h> #include <glib/gstdio.h> #include <glib/gprintf.h> #include <glib-object.h> @@ -657,6 +658,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, @@ -706,6 +710,10 @@ 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: '%s'"), filename); + return FALSE; } #endif |