Fix std/png decode_other_chunk skipping chunks

This commit is contained in:
Nigel Tao committed 2021-11-09 22:10:00 +11:00
1 parent 2373340f83
commit 9c3d27fb43
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -37883,7 +37883,8 @@ wuffs_png__decoder__decode_other_chunk(
goto suspend; goto suspend;
} }
self->private_impl.f_seen_trns = true; self->private_impl.f_seen_trns = true;
} else { }
if (self->private_impl.f_metadata_fourcc == 0) {
self->private_data.s_decode_other_chunk[0].scratch = self->private_impl.f_chunk_length; self->private_data.s_decode_other_chunk[0].scratch = self->private_impl.f_chunk_length;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
if (self->private_data.s_decode_other_chunk[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_decode_other_chunk[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
@@ -38416,6 +38417,7 @@ wuffs_png__decoder__decode_plte(
goto exit; goto exit;
} }
v_num_entries = (((uint32_t)(self->private_impl.f_chunk_length)) / 3); v_num_entries = (((uint32_t)(self->private_impl.f_chunk_length)) / 3);
self->private_impl.f_chunk_length = 0;
while (v_i < v_num_entries) { while (v_i < v_num_entries) {
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
+3 -1
View File
@@ -495,8 +495,9 @@ pri func decoder.decode_other_chunk?(src: base.io_reader) {
} }
this.decode_trns?(src: args.src) this.decode_trns?(src: args.src)
this.seen_trns = true this.seen_trns = true
}
} else { if this.metadata_fourcc == 0 {
args.src.skip?(n: this.chunk_length) args.src.skip?(n: this.chunk_length)
} }
} }
@@ -591,6 +592,7 @@ pri func decoder.decode_plte?(src: base.io_reader) {
return "#bad chunk" return "#bad chunk"
} }
num_entries = (this.chunk_length as base.u32) / 3 num_entries = (this.chunk_length as base.u32) / 3
this.chunk_length = 0
while i < num_entries { while i < num_entries {
assert i < 256 via "a < b: a < c; c <= b"(c: num_entries) assert i < 256 via "a < b: a < c; c <= b"(c: num_entries)