From 5f62c43313b515bac3a902001c2290c19cac1d9c Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 20 Jun 2026 09:39:55 +1000 Subject: [PATCH] Check PyList_Append return value --- src/_imagingmorph.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/_imagingmorph.c b/src/_imagingmorph.c index b6f307c849e..72d12f8b848 100644 --- a/src/_imagingmorph.c +++ b/src/_imagingmorph.c @@ -198,8 +198,12 @@ match(PyObject *self, PyObject *args) { Py_DECREF(ret); return NULL; } - PyList_Append(ret, coordObj); - Py_XDECREF(coordObj); + if (PyList_Append(ret, coordObj) == -1) { + Py_DECREF(ret); + Py_DECREF(coordObj); + return NULL; + } + Py_DECREF(coordObj); } } } @@ -250,8 +254,12 @@ get_on_pixels(PyObject *self, PyObject *args) { Py_DECREF(ret); return NULL; } - PyList_Append(ret, coordObj); - Py_XDECREF(coordObj); + if (PyList_Append(ret, coordObj) == -1) { + Py_DECREF(ret); + Py_DECREF(coordObj); + return NULL; + } + Py_DECREF(coordObj); } } }