From d96f30e9d307b94e15035b060e80bd0d3d872116 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 20 Jun 2026 11:37:56 +1000 Subject: [PATCH] Free image bands on error --- src/_imaging.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/_imaging.c b/src/_imaging.c index 12cd3ddc753..4bc09abd997 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -2489,11 +2489,17 @@ _split(ImagingObject *self, PyObject *args) { list = PyTuple_New(self->image->bands); if (!list) { + for (int j = 0; j < self->image->bands; j++) { + ImagingDelete(bands[j]); + } return NULL; } for (i = 0; i < self->image->bands; i++) { imaging_object = PyImagingNew(bands[i]); if (!imaging_object) { + for (int j = 0; j < self->image->bands; j++) { + ImagingDelete(bands[j]); + } Py_DECREF(list); list = NULL; break;