@@ -188,12 +188,20 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr)
188188 jas_logerrorf ("heif_context_alloc failed\n" );
189189 goto error ;
190190 }
191- #if 0
192- #endif
193- heif_context_read_from_memory_without_copy (ctx , ptr , size , 0 );
191+
192+ struct heif_error err ;
193+ err = heif_context_read_from_memory_without_copy (ctx , ptr , size , 0 );
194+ if (err .code != 0 ) {
195+ jas_logerrorf ("heif_context_read_from_memory_without_copy failed\n" );
196+ goto error ;
197+ }
194198
195199 /* Get a handle to the primary image. */
196- heif_context_get_primary_image_handle (ctx , & handle );
200+ err = heif_context_get_primary_image_handle (ctx , & handle );
201+ if (err .code != 0 ) {
202+ jas_logerrorf ("heif_context_get_primary_image_handle failed\n" );
203+ goto error ;
204+ }
197205
198206 int width = heif_image_handle_get_width (handle );
199207 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)
218226
219227 /* Decode the image and convert the colorspace to RGB,
220228 saved as 24bit interleaved. */
221- struct heif_error err ;
222229 err = heif_decode_image (handle , & img , heif_colorspace_RGB ,
223230 heif_chroma_interleaved_RGB , 0 );
224231 if (err .code != 0 ) {
@@ -247,6 +254,7 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr)
247254 for (cmptno = 0 ; cmptno < numcmpts ; ++ cmptno ) {
248255 if (width > JAS_IMAGE_COORD_MAX ||
249256 height > JAS_IMAGE_COORD_MAX ) {
257+ jas_logerrorf ("image size too large\n" );
250258 goto error ;
251259 }
252260 cmptparm .tlx = 0 ;
@@ -290,6 +298,8 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr)
290298 data [3 * width * y + 3 * x + cmptno ]);
291299 }
292300 if (jas_image_writecmpt (image , cmptno , 0 , y , width , 1 , matrix )) {
301+ jas_logerrorf ("jas_image_writecmpt failed\n" );
302+ goto error ;
293303 }
294304 }
295305 }
0 commit comments