diff --git a/data/test/bad/383.heic b/data/test/bad/383.heic new file mode 100644 index 00000000..f2f58795 Binary files /dev/null and b/data/test/bad/383.heic differ diff --git a/src/libjasper/heic/heic_dec.c b/src/libjasper/heic/heic_dec.c index cde38435..1716d580 100644 --- a/src/libjasper/heic/heic_dec.c +++ b/src/libjasper/heic/heic_dec.c @@ -188,12 +188,20 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr) jas_logerrorf("heif_context_alloc failed\n"); goto error; } -#if 0 -#endif - heif_context_read_from_memory_without_copy(ctx, ptr, size, 0); + + struct heif_error err; + err = heif_context_read_from_memory_without_copy(ctx, ptr, size, 0); + if (err.code != 0) { + jas_logerrorf("heif_context_read_from_memory_without_copy failed\n"); + goto error; + } /* Get a handle to the primary image. */ - heif_context_get_primary_image_handle(ctx, &handle); + err = heif_context_get_primary_image_handle(ctx, &handle); + if (err.code != 0) { + jas_logerrorf("heif_context_get_primary_image_handle failed\n"); + goto error; + } int width = heif_image_handle_get_width(handle); int height = heif_image_handle_get_height(handle); @@ -218,7 +226,6 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr) /* Decode the image and convert the colorspace to RGB, saved as 24bit interleaved. */ - struct heif_error err; err = heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_RGB, 0); if (err.code != 0) { @@ -247,6 +254,7 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr) for (cmptno = 0; cmptno < numcmpts; ++cmptno) { if (width > JAS_IMAGE_COORD_MAX || height > JAS_IMAGE_COORD_MAX) { + jas_logerrorf("image size too large\n"); goto error; } cmptparm.tlx = 0; @@ -290,6 +298,8 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr) data[3 * width * y + 3 * x + cmptno]); } if (jas_image_writecmpt(image, cmptno, 0, y, width, 1, matrix)) { + jas_logerrorf("jas_image_writecmpt failed\n"); + goto error; } } } diff --git a/test/bin/run_test_1 b/test/bin/run_test_1 index 24cb9878..eb8172c7 100755 --- a/test/bin/run_test_1 +++ b/test/bin/run_test_1 @@ -46,10 +46,15 @@ has_jpg="$(is_supported_format jpg)" || \ panic "cannot determine if JPG is supported format" has_mif="$(is_supported_format mif)" || \ panic "cannot determine if MIF is supported format" +has_heic="$(is_supported_format heic)" || \ + panic "cannot determine if HEIF is supported format" if [ "$internal_testing_mode" -ne 0 -a "$has_mif" -eq 0 ]; then echo "warning: MIF support is missing" fi +if [ "$internal_testing_mode" -ne 0 -a "$has_heic" -eq 0 ]; then + echo "warning: HEIF support is missing" +fi if [ "$has_jpg" -eq 0 ]; then echo "warning: JPEG support is missing" fi @@ -70,6 +75,11 @@ for file in "$data_dir"/test/good/*.*; do skip=1 fi ;; + *.heic) + if [ "$has_heic" -eq 0 ]; then + skip=1 + fi + ;; *.txt) skip=1 ;;