diff -urNp old/src/libjasper/jp2/jp2_enc.c new/src/libjasper/jp2/jp2_enc.c
--- old/src/libjasper/jp2/jp2_enc.c 2018-06-21 09:46:45.090301777 +0200
+++ new/src/libjasper/jp2/jp2_enc.c 2018-06-21 10:18:17.602305787 +0200
@@ -115,6 +115,11 @@ int sgnd;
iccstream = 0;
iccprof = 0;
+ if (jas_image_numcmpts(image) < 1) {
+ // jas_eprintf("image must have at least one component\n");
+ goto error;
+ }
+
allcmptssame = 1;
sgnd = jas_image_cmptsgnd(image, 0);
prec = jas_image_cmptprec(image, 0);