diff --git a/image_utils.c b/image_utils.c index 422847a..e616557 100644 --- a/image_utils.c +++ b/image_utils.c @@ -237,6 +237,7 @@ image_new(int32_t width, int32_t height) if((vimage->buf = (pix *)malloc(width * height * sizeof(pix))) == NULL) { DPRINTF(E_WARN, L_METADATA, "malloc failed\n"); + free(vimage); return NULL; } return(vimage); @@ -291,6 +292,20 @@ image_new_from_jpeg(const char * path, int is_file, const char * buf, int size) return NULL; } + if( setjmp(setjmp_buffer) ) + { + jpeg_destroy_decompress(&cinfo); + if( is_file && file ) + fclose(file); + if( vimage ) + { + if( vimage->buf ) + free(vimage->buf); + free(vimage); + } + return NULL; + } + if(cinfo.rec_outbuf_height > 16) { DPRINTF(E_WARN, L_METADATA, "ERROR image_from_jpeg : (image_from_jpeg.c) JPEG uses line buffers > 16. Cannot load.\n");