Tweak wuffs_gif__quirk_reject_empty_frame
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c
index dbf5a7b..05634ca 100644
--- a/release/c/wuffs-unsupported-snapshot.c
+++ b/release/c/wuffs-unsupported-snapshot.c
@@ -9395,6 +9395,14 @@
goto suspend;
}
}
+ if (self->private_impl.f_quirk_enabled_reject_empty_frame &&
+ ((self->private_impl.f_frame_rect_x0 ==
+ self->private_impl.f_frame_rect_x1) ||
+ (self->private_impl.f_frame_rect_y0 ==
+ self->private_impl.f_frame_rect_y1))) {
+ status = wuffs_gif__error__bad_frame_size;
+ goto exit;
+ }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
status = wuffs_gif__decoder__decode_id_part1(self, a_dst, a_src);
if (status) {
@@ -10605,14 +10613,6 @@
self->private_impl.f_frame_rect_y1 += self->private_impl.f_frame_rect_y0;
self->private_impl.f_dst_x = self->private_impl.f_frame_rect_x0;
self->private_impl.f_dst_y = self->private_impl.f_frame_rect_y0;
- if (self->private_impl.f_quirk_enabled_reject_empty_frame &&
- ((self->private_impl.f_frame_rect_x0 ==
- self->private_impl.f_frame_rect_x1) ||
- (self->private_impl.f_frame_rect_y0 ==
- self->private_impl.f_frame_rect_y1))) {
- status = wuffs_gif__error__bad_frame_size;
- goto exit;
- }
if ((self->private_impl.f_call_sequence == 0) &&
!self->private_impl.f_quirk_enabled_image_bounds_are_strict) {
self->private_impl.f_width = wuffs_base__u32__max(
diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs
index e999ff2..04200c3 100644
--- a/std/gif/decode_gif.wuffs
+++ b/std/gif/decode_gif.wuffs
@@ -101,7 +101,8 @@
// buffer with that color.
pub const quirk_background_is_opaque base.u32 = (0xF8586 << 10) | 3
-// When this quirk is enabled, a frame with zero width or height is rejected.
+// When this quirk is enabled, a frame with zero width or height is rejected
+// during decode_frame (but accepted during decode_frame_config).
pub const quirk_reject_empty_frame base.u32 = (0xF8586 << 10) | 5
// When this quirk is enabled, a frame with no explicit palette is rejected,
@@ -472,6 +473,10 @@
if this.call_sequence <> 4 {
this.decode_frame_config?(dst:nullptr, src:args.src)
}
+ if this.quirk_enabled_reject_empty_frame and
+ ((this.frame_rect_x0 == this.frame_rect_x1) or (this.frame_rect_y0 == this.frame_rect_y1)) {
+ return "#bad frame size"
+ }
this.decode_id_part1?(dst:args.dst, src:args.src)
this.decode_id_part2?(dst:args.dst, src:args.src, workbuf:args.workbuf)
@@ -834,12 +839,6 @@
this.dst_x = this.frame_rect_x0
this.dst_y = this.frame_rect_y0
- if this.quirk_enabled_reject_empty_frame and
- ((this.frame_rect_x0 == this.frame_rect_x1) or
- (this.frame_rect_y0 == this.frame_rect_y1)) {
- return "#bad frame size"
- }
-
// Set the image's overall width and height to be the maximum of the
// nominal image width and height (given in the Logical Screen Descriptor)
// and the bottom right extent of the first frame. See
diff --git a/test/c/std/gif.c b/test/c/std/gif.c
index ee1d94b..52a82e6 100644
--- a/test/c/std/gif.c
+++ b/test/c/std/gif.c
@@ -1128,13 +1128,6 @@
status = wuffs_gif__decoder__decode_image_config(
&dec, &ic, wuffs_base__io_buffer__reader(&src));
if (status) {
- if (q == 2) {
- if (status != want) {
- RETURN_FAIL("q=%d: decode_image_config: got \"%s\", want \"%s\"", q,
- status, want);
- }
- continue;
- }
RETURN_FAIL("q=%d: decode_image_config: \"%s\"", q, status);
}
@@ -1145,12 +1138,11 @@
RETURN_FAIL("q=%d: set_from_slice: \"%s\"", q, status);
}
- status = wuffs_gif__decoder__decode_frame(
+ const char* got = wuffs_gif__decoder__decode_frame(
&dec, &pb, wuffs_base__io_buffer__reader(&src), global_work_slice,
NULL);
- if (status != want) {
- RETURN_FAIL("q=%d: decode_frame: got \"%s\", want \"%s\"", q, status,
- want);
+ if (got != want) {
+ RETURN_FAIL("q=%d: decode_frame: got \"%s\", want \"%s\"", q, got, want);
}
}
return NULL;