mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-05 04:13:11 +03:00
Fix memory leak when JpegEncode returns an error.
This commit is contained in:
parent
f792e0b1ef
commit
789631c60c
|
@ -131,6 +131,7 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) {
|
|||
break;
|
||||
default:
|
||||
state->errcode = IMAGING_CODEC_CONFIG;
|
||||
jpeg_destroy_compress(&context->cinfo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -161,6 +162,7 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) {
|
|||
/* Would subsample the green and blue
|
||||
channels, which doesn't make sense */
|
||||
state->errcode = IMAGING_CODEC_CONFIG;
|
||||
jpeg_destroy_compress(&context->cinfo);
|
||||
return -1;
|
||||
}
|
||||
jpeg_set_colorspace(&context->cinfo, JCS_RGB);
|
||||
|
|
Loading…
Reference in New Issue
Block a user