aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-06-04 19:16:00 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-06-04 19:19:16 +0200
commitac6b606ccc85c2fca02b6199ba138fd85f04489c (patch)
tree00f645d47b5c170998f78a2c42ee79975e05f94d
parent8bba456b1470b0e7f2c8291e50bff37c001d8f44 (diff)
downloadfiv-ac6b606ccc85c2fca02b6199ba138fd85f04489c.tar.gz
fiv-ac6b606ccc85c2fca02b6199ba138fd85f04489c.tar.xz
fiv-ac6b606ccc85c2fca02b6199ba138fd85f04489c.zip
Bump Wuffs, support partial PNGs through it
-rw-r--r--fiv-io.c21
-rw-r--r--fiv-thumbnail.c2
m---------wuffs-mirror-release-c0
3 files changed, 12 insertions, 11 deletions
diff --git a/fiv-io.c b/fiv-io.c
index a1ec9f6..dcec86a 100644
--- a/fiv-io.c
+++ b/fiv-io.c
@@ -589,7 +589,6 @@ load_wuffs_frame(struct load_wuffs_frame_context *ctx, GError **error)
WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL)
decode_format = CAIRO_FORMAT_ARGB32;
- bool success = false;
unsigned char *targetbuf = NULL;
cairo_surface_t *surface =
cairo_image_surface_create(decode_format, ctx->width, ctx->height);
@@ -627,7 +626,10 @@ load_wuffs_frame(struct load_wuffs_frame_context *ctx, GError **error)
WUFFS_BASE__PIXEL_BLEND__SRC, ctx->workbuf, NULL);
if (!wuffs_base__status__is_ok(&status)) {
set_error(error, wuffs_base__status__message(&status));
- goto fail;
+
+ // The PNG decoder, at minimum, will flush any pixel data, so use them.
+ if (status.repr != wuffs_base__suspension__short_read)
+ goto fail;
}
if (ctx->target) {
@@ -760,19 +762,17 @@ load_wuffs_frame(struct load_wuffs_frame_context *ctx, GError **error)
else
ctx->result = surface;
- success = true;
ctx->result_tail = surface;
ctx->last_fc = fc;
+ g_free(targetbuf);
+ return wuffs_base__status__is_ok(&status);
fail:
- if (!success) {
- cairo_surface_destroy(surface);
- g_clear_pointer(&ctx->result, cairo_surface_destroy);
- ctx->result_tail = NULL;
- }
-
+ cairo_surface_destroy(surface);
+ g_clear_pointer(&ctx->result, cairo_surface_destroy);
+ ctx->result_tail = NULL;
g_free(targetbuf);
- return success;
+ return false;
}
// https://github.com/google/wuffs/blob/main/example/gifplayer/gifplayer.c
@@ -2695,7 +2695,6 @@ fiv_io_open_from_data(
#ifdef HAVE_GDKPIXBUF // ------------------------------------------------------
// This is used as a last resort, the rest above is special-cased.
- // Wuffs #71 and similar concerns make us default to it in all cases.
if (!surface) {
GError *err = NULL;
if ((surface = open_gdkpixbuf(data, len, ctx, &err))) {
diff --git a/fiv-thumbnail.c b/fiv-thumbnail.c
index 2dfd15f..44f2735 100644
--- a/fiv-thumbnail.c
+++ b/fiv-thumbnail.c
@@ -425,8 +425,10 @@ read_wide_thumbnail(
bool sRGB = false;
GBytes *thum = cairo_surface_get_user_data(surface, &fiv_io_key_thum);
if (!thum) {
+ g_clear_error(error);
set_error(error, "not a thumbnail");
} else if (!check_wide_thumbnail_texts(thum, uri, mtime, &sRGB)) {
+ g_clear_error(error);
set_error(error, "mismatch");
} else {
// TODO(p): Add a function or a non-valueless define to check
diff --git a/wuffs-mirror-release-c b/wuffs-mirror-release-c
-Subproject cc74cb4d30f48c3f5e312e48a8ed87e009f62d9
+Subproject 123a5c6ede3c052aaf9bbef59afb9410baa2b40