* Fix a memory leak when encountering problems at a certain stage of compressing image data.
This commit is contained in:
parent
7e24abe127
commit
cf48b38485
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user