From 9089d375788906f7ba9e7ca3576587e7238f6771 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 5 Oct 2019 11:54:03 +1000 Subject: [PATCH] Clip std/gif replicated rows to the frame rect Updates https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17802 --- release/c/wuffs-unsupported-snapshot.c | 2 ++ std/gif/decode_gif.wuffs | 1 + test/c/std/gif.c | 5 ++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 9dcb62ad..c4daffc4 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -11183,6 +11183,8 @@ label_0_continue:; self->private_impl.f_dst_y, ((uint32_t)( wuffs_gif__interlace_count[self->private_impl.f_interlace]))); + v_replicate_y1 = wuffs_base__u32__min( + v_replicate_y1, self->private_impl.f_frame_rect_y1); while (v_replicate_y0 < v_replicate_y1) { v_replicate_dst = wuffs_base__table_u8__row(v_tab, v_replicate_y0); wuffs_base__slice_u8__copy_from_slice(v_replicate_dst, diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index c06f21ab..e42b588f 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -1182,6 +1182,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base. replicate_src = tab.row(y:this.dst_y) replicate_y0 = this.dst_y ~sat+ 1 replicate_y1 = this.dst_y ~sat+ (interlace_count[this.interlace] as base.u32) + replicate_y1 = replicate_y1.min(a:this.frame_rect_y1) while replicate_y0 < replicate_y1 { assert replicate_y0 < 0xFFFFFFFF via "a < b: a < c; c <= b"(c:replicate_y1) replicate_dst = tab.row(y:replicate_y0) diff --git a/test/c/std/gif.c b/test/c/std/gif.c index 1fae1539..e4d9a6b4 100644 --- a/test/c/std/gif.c +++ b/test/c/std/gif.c @@ -2085,9 +2085,8 @@ const char* test_wuffs_gif_small_frame_interlaced() { } wuffs_base__rect_ie_u32 dr = wuffs_gif__decoder__frame_dirty_rect(&dec); - // TODO: it's a bug that the frame rect doesn't contain the dirty rect. - if (dr.max_excl_y != 5) { - RETURN_FAIL("dirty rect max_excl_y: got %" PRIu32 ", want 5", + if (dr.max_excl_y != 3) { + RETURN_FAIL("dirty rect max_excl_y: got %" PRIu32 ", want 3", dr.max_excl_y); }