diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-05-20 23:46:39 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-05-21 23:31:41 +0200 |
commit | 00110a639aea03250476a32349fd9093d54b2c46 (patch) | |
tree | e85cba728c7a23a9d6bff26950deb014a6d0e0da /fiv-thumbnail.c | |
parent | 5af36f49540533359782b0ac202e4eb8ff14928d (diff) | |
download | fiv-00110a639aea03250476a32349fd9093d54b2c46.tar.gz fiv-00110a639aea03250476a32349fd9093d54b2c46.tar.xz fiv-00110a639aea03250476a32349fd9093d54b2c46.zip |
Avoid use of NULL picture data pointers
The sanitizer would scream, and LibRaw would rather confusingly
return I/O errors.
Diffstat (limited to 'fiv-thumbnail.c')
-rw-r--r-- | fiv-thumbnail.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fiv-thumbnail.c b/fiv-thumbnail.c index c552073..0933951 100644 --- a/fiv-thumbnail.c +++ b/fiv-thumbnail.c @@ -281,6 +281,12 @@ fiv_thumbnail_extract(GFile *target, FivThumbnailSize max_size, GError **error) // TODO(p): Implement our own thumbnail extractors. set_error(error, "unsupported file"); #else // HAVE_LIBRAW + // In this case, g_mapped_file_get_contents() returns NULL, causing issues. + if (!g_mapped_file_get_length(mf)) { + set_error(error, "empty file"); + goto fail; + } + libraw_data_t *iprc = libraw_init( LIBRAW_OPIONS_NO_MEMERR_CALLBACK | LIBRAW_OPIONS_NO_DATAERR_CALLBACK); if (!iprc) { @@ -535,7 +541,13 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error) return produce_fallback(target, max_size, error); } + // In this case, g_mapped_file_get_bytes() has NULL data, causing issues. gsize filesize = g_mapped_file_get_length(mf); + if (!filesize) { + set_error(error, "empty file"); + return NULL; + } + gboolean color_managed = FALSE; cairo_surface_t *surface = render(target, g_mapped_file_get_bytes(mf), &color_managed, error); |