From b97a1eee253c13cfda3c32732bdbc82b9a4b5271 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 16 Apr 2015 14:33:57 +0100 Subject: [PATCH] Add Py_DECREF for each sequence returned by PySequence_Fast, so that these sequences are not leaked. Fixes #1187. --- _imaging.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_imaging.c b/_imaging.c index 786363e24..8242da670 100644 --- a/_imaging.c +++ b/_imaging.c @@ -422,6 +422,7 @@ getlist(PyObject* arg, int* length, const char* wrong_length, int type) PyErr_Clear(); + Py_DECREF(seq); return list; } @@ -1289,6 +1290,7 @@ _putdata(ImagingObject* self, PyObject* args) } } PyErr_Clear(); /* Avoid weird exceptions */ + Py_DECREF(seq); } } else { /* 32-bit images */ @@ -1340,6 +1342,7 @@ _putdata(ImagingObject* self, PyObject* args) PyErr_Clear(); /* Avoid weird exceptions */ break; } + Py_DECREF(seq); } Py_INCREF(Py_None);