opj_jp2_check_color(): replace assertion regarding mtyp by runtime check (#672, #895)

Fixes test case openjeg-crashes-2017-07-27/id:000000,sig:06,src:000001,op:flip1,pos:808.jp2
of #895
This commit is contained in:
Even Rouault 2017-07-27 18:51:51 +02:00
parent d6fa300997
commit 178194c093
1 changed files with 7 additions and 2 deletions

View File

@ -950,8 +950,13 @@ static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color,
/* verify that no component is targeted more than once */ /* verify that no component is targeted more than once */
for (i = 0; i < nr_channels; i++) { for (i = 0; i < nr_channels; i++) {
OPJ_UINT16 pcol = cmap[i].pcol; OPJ_UINT16 pcol = cmap[i].pcol;
assert(cmap[i].mtyp == 0 || cmap[i].mtyp == 1); /* See ISO 15444-1 Table I.14 MTYPi field values */
if (pcol >= nr_channels) { if (cmap[i].mtyp != 0 && cmap[i].mtyp != 1) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid value for cmap[%d].mtyp = %d.\n", i,
cmap[i].mtyp);
is_sane = OPJ_FALSE;
} else if (pcol >= nr_channels) {
opj_event_msg(p_manager, EVT_ERROR, opj_event_msg(p_manager, EVT_ERROR,
"Invalid component/palette index for direct mapping %d.\n", pcol); "Invalid component/palette index for direct mapping %d.\n", pcol);
is_sane = OPJ_FALSE; is_sane = OPJ_FALSE;