Avoid use of NULL picture data pointers
The sanitizer would scream, and LibRaw would rather confusingly return I/O errors.
This commit is contained in:
parent
5af36f4954
commit
00110a639a
|
@ -281,6 +281,12 @@ fiv_thumbnail_extract(GFile *target, FivThumbnailSize max_size, GError **error)
|
||||||
// TODO(p): Implement our own thumbnail extractors.
|
// TODO(p): Implement our own thumbnail extractors.
|
||||||
set_error(error, "unsupported file");
|
set_error(error, "unsupported file");
|
||||||
#else // HAVE_LIBRAW
|
#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_data_t *iprc = libraw_init(
|
||||||
LIBRAW_OPIONS_NO_MEMERR_CALLBACK | LIBRAW_OPIONS_NO_DATAERR_CALLBACK);
|
LIBRAW_OPIONS_NO_MEMERR_CALLBACK | LIBRAW_OPIONS_NO_DATAERR_CALLBACK);
|
||||||
if (!iprc) {
|
if (!iprc) {
|
||||||
|
@ -535,7 +541,13 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error)
|
||||||
return produce_fallback(target, max_size, 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);
|
gsize filesize = g_mapped_file_get_length(mf);
|
||||||
|
if (!filesize) {
|
||||||
|
set_error(error, "empty file");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean color_managed = FALSE;
|
gboolean color_managed = FALSE;
|
||||||
cairo_surface_t *surface =
|
cairo_surface_t *surface =
|
||||||
render(target, g_mapped_file_get_bytes(mf), &color_managed, error);
|
render(target, g_mapped_file_get_bytes(mf), &color_managed, error);
|
||||||
|
|
Loading…
Reference in New Issue