From 596e80c6545d32c123525e85d29b6de1692e5a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ila=C3=AF=20Deutel?= Date: Thu, 28 Oct 2021 18:15:43 +0000 Subject: [PATCH] WebP: Fix memory leak during decoding on failure When creating the `WebPAnimDecoder` object, we create a `WebPAnimDecoderObject` and populate its data using `WebPDataCopy()`. Subsequently, if either `WebPAnimDecoderNew()` or `WebPAnimDecoderGetInfo()` fails, data is not currently deallocated. This commit clears the decoder object's data in that situation. --- src/_webp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_webp.c b/src/_webp.c index 6c357dbb0..90719b466 100644 --- a/src/_webp.c +++ b/src/_webp.c @@ -392,6 +392,7 @@ _anim_decoder_new(PyObject *self, PyObject *args) { return (PyObject *)decp; } } + WebPDataClear(&(decp->data)); } PyObject_Del(decp); }