summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2017-07-27 18:51:51 +0200
committerEven Rouault <even.rouault@spatialys.com>2017-07-27 18:52:35 +0200
commit178194c093422c9564efc41f9ecb5c630b43f723 (patch)
treea10944936b4e4546aa28d9e9908763be060bbfe7 /src
parentd6fa30099797c68c6a67decf58571dd59dbf734b (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/lib/openjp2/jp2.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c
index ab708758..f9a74a99 100644
--- a/src/lib/openjp2/jp2.c
+++ b/src/lib/openjp2/jp2.c
@@ -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 */
for (i = 0; i < nr_channels; i++) {
OPJ_UINT16 pcol = cmap[i].pcol;
- assert(cmap[i].mtyp == 0 || cmap[i].mtyp == 1);
- if (pcol >= nr_channels) {
+ /* See ISO 15444-1 Table I.14 – MTYPi field values */
+ 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,
"Invalid component/palette index for direct mapping %d.\n", pcol);
is_sane = OPJ_FALSE;