diff options
| author | szukw000 <szukw000@arcor.de> | 2020-04-17 00:37:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-17 00:37:33 +0200 |
| commit | b6b7e96b0cf7819ef6a2e8ba2f8bdaaf938326ed (patch) | |
| tree | d18182c1ed63507bb43c7dc95dae817468363ed8 /src | |
| parent | 040e142288e90c9c2d46d25d0a27f828f968bb93 (diff) | |
color_apply_icc_profile: add checks on the number of components (#1236)
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/common/color.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bin/common/color.c b/src/bin/common/color.c index d3a2f38d..27f15f13 100644 --- a/src/bin/common/color.c +++ b/src/bin/common/color.c @@ -488,6 +488,10 @@ void color_apply_icc_profile(opj_image_t *image) if (out_space == cmsSigRgbData) { /* enumCS 16 */ unsigned int i, nr_comp = image->numcomps; + if (nr_comp < 3) { /* GRAY or GRAYA, not RGB or RGBA */ + cmsCloseProfile(in_prof); + return; + } if (nr_comp > 4) { nr_comp = 4; } @@ -529,6 +533,10 @@ void color_apply_icc_profile(opj_image_t *image) out_prof = cmsCreate_sRGBProfile(); new_space = OPJ_CLRSPC_SRGB; } else if (out_space == cmsSigYCbCrData) { /* enumCS 18 */ + if (image->numcomps < 3) { + cmsCloseProfile(in_prof); + return; + } in_type = TYPE_YCbCr_16; out_type = TYPE_RGB_16; out_prof = cmsCreate_sRGBProfile(); |
