From 348e6cd26242e7bfb703ff3c174bc4dc5d80d23e Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 5 Jan 2025 17:22:22 +1100 Subject: [PATCH] Destroy image on failure --- src/_avif.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/_avif.c b/src/_avif.c index c4728762531..7eeac1241c3 100644 --- a/src/_avif.c +++ b/src/_avif.c @@ -289,6 +289,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { image->yuvRange = AVIF_RANGE_LIMITED; } else { PyErr_SetString(PyExc_ValueError, "Invalid range"); + avifImageDestroy(image); return NULL; } if (strcmp(subsampling, "4:0:0") == 0) { @@ -301,6 +302,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { image->yuvFormat = AVIF_PIXEL_FORMAT_YUV444; } else { PyErr_Format(PyExc_ValueError, "Invalid subsampling: %s", subsampling); + avifImageDestroy(image); return NULL; }