diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 320e924c..15cf5a36 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -49070,14 +49070,14 @@ wuffs_jpeg__decoder__do_decode_image_config( } self->private_impl.f_payload_length = t_4; } - if (self->private_impl.f_payload_length >= 2u) { - self->private_impl.f_payload_length -= 2u; - } else if ((v_marker == 254u) || ((224u <= v_marker) && (v_marker < 240u))) { - continue; - } else { + if (self->private_impl.f_payload_length < 2u) { + if ((v_marker == 254u) || ((224u <= v_marker) && (v_marker < 240u))) { + continue; + } status = wuffs_base__make_status(wuffs_jpeg__error__bad_marker); goto exit; } + self->private_impl.f_payload_length -= 2u; } if (v_marker < 192u) { status = wuffs_base__make_status(wuffs_jpeg__error__unsupported_marker); diff --git a/std/jpeg/decode_jpeg.wuffs b/std/jpeg/decode_jpeg.wuffs index 40ee683f..57541954 100644 --- a/std/jpeg/decode_jpeg.wuffs +++ b/std/jpeg/decode_jpeg.wuffs @@ -426,18 +426,18 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base. } else { this.payload_length = args.src.read_u16be_as_u32?() // Payload length includes the 2 bytes for the u16be just read. - if this.payload_length >= 2 { - this.payload_length -= 2 - } else if (marker == 0xFE) or // COM. - ((0xE0 <= marker) and (marker < 0xF0)) { // APPn. - // Strictly speaking, this is invalid according to Section - // B.1.1.4 "Marker segments". However, libjpeg-turbo allows it - // (for COM and APPn markers; see its jdmarker.c file's - // skip_variable function) so we do too. - continue - } else { + if this.payload_length < 2 { + if (marker == 0xFE) or // COM. + ((0xE0 <= marker) and (marker < 0xF0)) { // APPn. + // Strictly speaking, this is invalid according to Section + // B.1.1.4 "Marker segments". However, libjpeg-turbo allows + // it (for COM and APPn markers; see its jdmarker.c file's + // skip_variable function) so we do too. + continue + } return "#bad marker" } + this.payload_length -= 2 } // Switch on the marker.