mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-23 19:44:13 +03:00
fix another memory leak
This commit is contained in:
parent
873d9ec089
commit
8c69132579
1
decode.c
1
decode.c
|
@ -779,6 +779,7 @@ PyImaging_ZipDecoderNew(PyObject* self, PyObject* args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
decoder->decode = ImagingZipDecode;
|
decoder->decode = ImagingZipDecode;
|
||||||
|
decoder->cleanup = ImagingZipDecodeCleanup;
|
||||||
|
|
||||||
((ZIPSTATE*)decoder->state.context)->interlaced = interlaced;
|
((ZIPSTATE*)decoder->state.context)->interlaced = interlaced;
|
||||||
|
|
||||||
|
|
|
@ -455,6 +455,7 @@ extern int ImagingXbmEncode(Imaging im, ImagingCodecState state,
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
extern int ImagingZipDecode(Imaging im, ImagingCodecState state,
|
extern int ImagingZipDecode(Imaging im, ImagingCodecState state,
|
||||||
UINT8* buffer, int bytes);
|
UINT8* buffer, int bytes);
|
||||||
|
extern int ImagingZipDecodeCleanup(ImagingCodecState state);
|
||||||
extern int ImagingZipEncode(Imaging im, ImagingCodecState state,
|
extern int ImagingZipEncode(Imaging im, ImagingCodecState state,
|
||||||
UINT8* buffer, int bytes);
|
UINT8* buffer, int bytes);
|
||||||
extern int ImagingZipEncodeCleanup(ImagingCodecState state);
|
extern int ImagingZipEncodeCleanup(ImagingCodecState state);
|
||||||
|
|
|
@ -86,6 +86,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
state->errcode = IMAGING_CODEC_CONFIG;
|
state->errcode = IMAGING_CODEC_CONFIG;
|
||||||
free(context->previous);
|
free(context->previous);
|
||||||
|
context->previous = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +128,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
else
|
else
|
||||||
state->errcode = IMAGING_CODEC_CONFIG;
|
state->errcode = IMAGING_CODEC_CONFIG;
|
||||||
free(context->previous);
|
free(context->previous);
|
||||||
|
context->previous = NULL;
|
||||||
inflateEnd(&context->z_stream);
|
inflateEnd(&context->z_stream);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -192,6 +194,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
default:
|
default:
|
||||||
state->errcode = IMAGING_CODEC_UNKNOWN;
|
state->errcode = IMAGING_CODEC_UNKNOWN;
|
||||||
free(context->previous);
|
free(context->previous);
|
||||||
|
context->previous = NULL;
|
||||||
inflateEnd(&context->z_stream);
|
inflateEnd(&context->z_stream);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +262,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
state->errcode = IMAGING_CODEC_BROKEN; */
|
state->errcode = IMAGING_CODEC_BROKEN; */
|
||||||
|
|
||||||
free(context->previous);
|
free(context->previous);
|
||||||
|
context->previous = NULL;
|
||||||
inflateEnd(&context->z_stream);
|
inflateEnd(&context->z_stream);
|
||||||
return -1; /* end of file (errcode=0) */
|
return -1; /* end of file (errcode=0) */
|
||||||
|
|
||||||
|
@ -275,4 +279,20 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ImagingZipDecodeCleanup(ImagingCodecState state){
|
||||||
|
/* called to fee the decompression engine when the decode terminates
|
||||||
|
due to a corrupt or truncated image
|
||||||
|
*/
|
||||||
|
ZIPSTATE* context = (ZIPSTATE*) state->context;
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
if (context->previous) {
|
||||||
|
inflateEnd(&context->z_stream);
|
||||||
|
free(context->previous);
|
||||||
|
context->previous = NULL;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user