jp2: convert: fix null pointer dereference

Tile components in a JP2 image might have null data pointer by defining a
zero component size (for example using large horizontal or vertical
sampling periods). This null data pointer leads to null image component
data pointer, causing crash when dereferenced without != null check in
imagetopnm.

Add != null check.

This commit addresses #1152 (CVE-2018-18088).
This commit is contained in:
Hugo Lefeuvre 2018-11-07 18:48:29 +01:00
parent 0bc90e4062
commit cab352e249
1 changed files with 5 additions and 0 deletions

View File

@ -2233,6 +2233,11 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
opj_version(), wr, hr, max);
red = image->comps[compno].data;
if (!red) {
fclose(fdest);
continue;
}
adjustR =
(image->comps[compno].sgnd ? 1 << (image->comps[compno].prec - 1) : 0);