summaryrefslogtreecommitdiff
path: root/src/bin/jp2/converttif.c
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-04-01 20:58:55 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-04-01 21:11:36 +0200
commit1c54024165fd5db0e6047f28903274eb27d0980f (patch)
tree86ce2c02bf2cc2f11cab5bd7130a66d4ce34381c /src/bin/jp2/converttif.c
parent563ecfb55ca77c0fc5ea19e4885e00f55ec82ca9 (diff)
opj_decompress: add sanity checks to avoid segfault in case of decoding error
Prevent crashes like: opj_decompress -i 0722_5-1_2019.jp2 -o out.ppm -r 4 -t 0 where 0722_5-1_2019.jp2 is https://drive.google.com/file/d/1ZxOUZg2-FKjYwa257VFLMpTXRWxEoP0a/view?usp=sharing
Diffstat (limited to 'src/bin/jp2/converttif.c')
-rw-r--r--src/bin/jp2/converttif.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bin/jp2/converttif.c b/src/bin/jp2/converttif.c
index 6714d69c..9d1037ac 100644
--- a/src/bin/jp2/converttif.c
+++ b/src/bin/jp2/converttif.c
@@ -616,6 +616,12 @@ int imagetotif(opj_image_t * image, const char *outfile)
break;
}
planes[i] = image->comps[i].data;
+ if (planes[i] == NULL) {
+ fprintf(stderr,
+ "imagetotif: planes[%d] == NULL.\n", i);
+ fprintf(stderr, "\tAborting\n");
+ return 1;
+ }
}
if (i != numcomps) {
fprintf(stderr,