Fix std/png tell_me_more minfo with suspensions

This commit is contained in:
Nigel Tao committed 2021-11-17 13:04:04 +11:00
1 parent e7ed1dd43e
commit e0cdaeb54f
2 files changed
+11 -14

No files matched your search

+7 -9
View File
@@ -40507,6 +40507,7 @@ wuffs_png__decoder__tell_me_more(
} }
self->private_impl.f_zlib_is_dirty = true; self->private_impl.f_zlib_is_dirty = true;
} }
label__loop__continue:;
while (true) { while (true) {
if (a_minfo != NULL) { if (a_minfo != NULL) {
wuffs_base__more_information__set(a_minfo, wuffs_base__more_information__set(a_minfo,
@@ -40663,36 +40664,33 @@ wuffs_png__decoder__tell_me_more(
goto exit; goto exit;
} }
} else { } else {
label__0__continue:;
while (true) { while (true) {
if (self->private_impl.f_chunk_length <= 0) { if (self->private_impl.f_chunk_length <= 0) {
if (self->private_impl.f_metadata_fourcc == 1263947851) { if (self->private_impl.f_metadata_fourcc == 1263947851) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
} }
goto label__0__break; goto label__loop__break;
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) { } else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
goto label__0__continue; goto label__loop__continue;
} }
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src); v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
if (v_c == 0) { if (v_c == 0) {
self->private_impl.f_chunk_length -= 1; self->private_impl.f_chunk_length -= 1;
iop_a_src += 1; iop_a_src += 1;
goto label__0__break; goto label__loop__break;
} }
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) { if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
status = wuffs_base__make_status(wuffs_base__suspension__short_write); status = wuffs_base__make_status(wuffs_base__suspension__short_write);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
goto label__0__continue; goto label__loop__continue;
} }
self->private_impl.f_chunk_length -= 1; self->private_impl.f_chunk_length -= 1;
iop_a_src += 1; iop_a_src += 1;
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, v_c), iop_a_dst += 1); (wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, v_c), iop_a_dst += 1);
} }
label__0__break:;
goto label__loop__break;
} }
} }
label__loop__break:; label__loop__break:;
@@ -40753,10 +40751,10 @@ wuffs_png__decoder__tell_me_more(
v_c = t_5; v_c = t_5;
} }
if (v_c == 0) { if (v_c == 0) {
goto label__1__break; goto label__0__break;
} }
} }
label__1__break:; label__0__break:;
} }
} else if (self->private_impl.f_chunk_type == 1951945850) { } else if (self->private_impl.f_chunk_type == 1951945850) {
if (self->private_impl.f_chunk_length <= 0) { if (self->private_impl.f_chunk_length <= 0) {
+4 -5
View File
@@ -1423,27 +1423,26 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform
if this.metadata_fourcc == 'KVPK'be { if this.metadata_fourcc == 'KVPK'be {
return "#bad chunk" return "#bad chunk"
} }
break break.loop
} else if args.src.length() <= 0 { } else if args.src.length() <= 0 {
yield? base."$short read" yield? base."$short read"
continue continue.loop
} }
c = args.src.peek_u8() c = args.src.peek_u8()
if c == 0 { if c == 0 {
this.chunk_length -= 1 this.chunk_length -= 1
args.src.skip_u32_fast!(actual: 1, worst_case: 1) args.src.skip_u32_fast!(actual: 1, worst_case: 1)
break break.loop
} }
// TODO: Convert from Latin-1 to UTF-8. // TODO: Convert from Latin-1 to UTF-8.
if args.dst.length() <= 0 { if args.dst.length() <= 0 {
yield? base."$short write" yield? base."$short write"
continue continue.loop
} }
this.chunk_length -= 1 this.chunk_length -= 1
args.src.skip_u32_fast!(actual: 1, worst_case: 1) args.src.skip_u32_fast!(actual: 1, worst_case: 1)
args.dst.write_u8_fast!(a: c) args.dst.write_u8_fast!(a: c)
} endwhile } endwhile
break.loop
} }
} endwhile.loop } endwhile.loop