mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-01 00:17:27 +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; | ||||
| 
 | ||||
|     decoder->decode = ImagingZipDecode; | ||||
|     decoder->cleanup = ImagingZipDecodeCleanup; | ||||
| 
 | ||||
|     ((ZIPSTATE*)decoder->state.context)->interlaced = interlaced; | ||||
| 
 | ||||
|  |  | |||
|  | @ -455,6 +455,7 @@ extern int ImagingXbmEncode(Imaging im, ImagingCodecState state, | |||
| #ifdef	HAVE_LIBZ | ||||
| extern int ImagingZipDecode(Imaging im, ImagingCodecState state, | ||||
| 			    UINT8* buffer, int bytes); | ||||
| extern int ImagingZipDecodeCleanup(ImagingCodecState state); | ||||
| extern int ImagingZipEncode(Imaging im, ImagingCodecState state, | ||||
| 			    UINT8* buffer, int bytes); | ||||
| extern int ImagingZipEncodeCleanup(ImagingCodecState state); | ||||
|  |  | |||
|  | @ -86,6 +86,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) | |||
|         if (err < 0) { | ||||
|             state->errcode = IMAGING_CODEC_CONFIG; | ||||
|             free(context->previous); | ||||
|             context->previous = NULL; | ||||
|             return -1; | ||||
|         } | ||||
| 
 | ||||
|  | @ -127,6 +128,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) | |||
|             else | ||||
|                 state->errcode = IMAGING_CODEC_CONFIG; | ||||
|             free(context->previous); | ||||
|             context->previous = NULL; | ||||
|             inflateEnd(&context->z_stream); | ||||
|             return -1; | ||||
|         } | ||||
|  | @ -192,6 +194,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) | |||
|             default: | ||||
|                 state->errcode = IMAGING_CODEC_UNKNOWN; | ||||
|                 free(context->previous); | ||||
|                 context->previous = NULL; | ||||
|                 inflateEnd(&context->z_stream); | ||||
|                 return -1; | ||||
|             } | ||||
|  | @ -259,6 +262,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) | |||
|                 state->errcode = IMAGING_CODEC_BROKEN; */ | ||||
| 
 | ||||
|             free(context->previous); | ||||
|             context->previous = NULL; | ||||
|             inflateEnd(&context->z_stream); | ||||
|             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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user