Merge pull request #1170 from rouault/fix_color_apply_icc_profile
color_apply_icc_profile: avoid potential heap buffer overflow
This commit is contained in:
commit
e0f5212888
|
@ -597,6 +597,10 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||
}
|
||||
|
||||
if (image->numcomps > 2) { /* RGB, RGBA */
|
||||
if ((image->comps[0].w == image->comps[1].w &&
|
||||
image->comps[0].w == image->comps[2].w) &&
|
||||
(image->comps[0].h == image->comps[1].h &&
|
||||
image->comps[0].h == image->comps[2].h)) {
|
||||
if (prec <= 8) {
|
||||
unsigned char *inbuf, *outbuf, *in, *out;
|
||||
|
||||
|
@ -674,6 +678,12 @@ fails1:
|
|||
opj_image_data_free(inbuf);
|
||||
opj_image_data_free(outbuf);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"[ERROR] Image components should have the same width and height\n");
|
||||
cmsDeleteTransform(transform);
|
||||
return;
|
||||
}
|
||||
} else { /* image->numcomps <= 2 : GRAY, GRAYA */
|
||||
if (prec <= 8) {
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
|
|
Loading…
Reference in New Issue