Tweak std/png decode_other_chunk if-else chain

This commit is contained in:
Nigel Tao committed 2021-11-09 09:05:11 +11:00
1 parent 74c1dfce96
commit e847766b02
2 files changed
+24 -8

No files matched your search

+12 -4
View File
@@ -37790,7 +37790,8 @@ wuffs_png__decoder__decode_other_chunk(
goto suspend; goto suspend;
} }
self->private_impl.f_seen_plte = true; self->private_impl.f_seen_plte = true;
} else if ((self->private_impl.f_chunk_type == 1297238115) && self->private_impl.f_report_metadata_chrm) { } else if (self->private_impl.f_chunk_type == 1297238115) {
if (self->private_impl.f_report_metadata_chrm) {
if (self->private_impl.f_seen_chrm) { if (self->private_impl.f_seen_chrm) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
@@ -37807,7 +37808,9 @@ wuffs_png__decoder__decode_other_chunk(
goto suspend; goto suspend;
} }
self->private_impl.f_seen_chrm = true; self->private_impl.f_seen_chrm = true;
} else if ((self->private_impl.f_chunk_type == 1095582055) && self->private_impl.f_report_metadata_gama) { }
} else if (self->private_impl.f_chunk_type == 1095582055) {
if (self->private_impl.f_report_metadata_gama) {
if (self->private_impl.f_seen_gama) { if (self->private_impl.f_seen_gama) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
@@ -37824,7 +37827,9 @@ wuffs_png__decoder__decode_other_chunk(
goto suspend; goto suspend;
} }
self->private_impl.f_seen_gama = true; self->private_impl.f_seen_gama = true;
} else if ((self->private_impl.f_chunk_type == 1346585449) && self->private_impl.f_report_metadata_iccp) { }
} else if (self->private_impl.f_chunk_type == 1346585449) {
if (self->private_impl.f_report_metadata_iccp) {
if (self->private_impl.f_seen_iccp) { if (self->private_impl.f_seen_iccp) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
@@ -37841,7 +37846,9 @@ wuffs_png__decoder__decode_other_chunk(
goto suspend; goto suspend;
} }
self->private_impl.f_seen_iccp = true; self->private_impl.f_seen_iccp = true;
} else if ((self->private_impl.f_chunk_type == 1111970419) && self->private_impl.f_report_metadata_srgb) { }
} else if (self->private_impl.f_chunk_type == 1111970419) {
if (self->private_impl.f_report_metadata_srgb) {
if (self->private_impl.f_seen_srgb) { if (self->private_impl.f_seen_srgb) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
@@ -37858,6 +37865,7 @@ wuffs_png__decoder__decode_other_chunk(
goto suspend; goto suspend;
} }
self->private_impl.f_seen_srgb = true; self->private_impl.f_seen_srgb = true;
}
} else if (self->private_impl.f_chunk_type == 1397641844) { } else if (self->private_impl.f_chunk_type == 1397641844) {
if (self->private_impl.f_seen_trns || (self->private_impl.f_color_type > 3) || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) { if (self->private_impl.f_seen_trns || (self->private_impl.f_color_type > 3) || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
+12 -4
View File
@@ -452,33 +452,41 @@ pri func decoder.decode_other_chunk?(src: base.io_reader) {
this.decode_plte?(src: args.src) this.decode_plte?(src: args.src)
this.seen_plte = true this.seen_plte = true
} else if (this.chunk_type == 'cHRM'le) and this.report_metadata_chrm { } else if this.chunk_type == 'cHRM'le {
if this.report_metadata_chrm {
if this.seen_chrm { if this.seen_chrm {
return "#bad chunk" return "#bad chunk"
} }
this.decode_chrm?(src: args.src) this.decode_chrm?(src: args.src)
this.seen_chrm = true this.seen_chrm = true
}
} else if (this.chunk_type == 'gAMA'le) and this.report_metadata_gama { } else if this.chunk_type == 'gAMA'le {
if this.report_metadata_gama {
if this.seen_gama { if this.seen_gama {
return "#bad chunk" return "#bad chunk"
} }
this.decode_gama?(src: args.src) this.decode_gama?(src: args.src)
this.seen_gama = true this.seen_gama = true
}
} else if (this.chunk_type == 'iCCP'le) and this.report_metadata_iccp { } else if this.chunk_type == 'iCCP'le {
if this.report_metadata_iccp {
if this.seen_iccp { if this.seen_iccp {
return "#bad chunk" return "#bad chunk"
} }
this.decode_iccp?(src: args.src) this.decode_iccp?(src: args.src)
this.seen_iccp = true this.seen_iccp = true
}
} else if (this.chunk_type == 'sRGB'le) and this.report_metadata_srgb { } else if this.chunk_type == 'sRGB'le {
if this.report_metadata_srgb {
if this.seen_srgb { if this.seen_srgb {
return "#bad chunk" return "#bad chunk"
} }
this.decode_srgb?(src: args.src) this.decode_srgb?(src: args.src)
this.seen_srgb = true this.seen_srgb = true
}
} else if this.chunk_type == 'tRNS'le { } else if this.chunk_type == 'tRNS'le {
if this.seen_trns or (this.color_type > 3) or if this.seen_trns or (this.color_type > 3) or