From: Bartosz Golaszewski Date: Fri, 13 Jul 2018 08:10:34 +0000 (+0200) Subject: bindings: python: fix a memory leak in error path X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ead4d6b46ac84d4c24dae8a92418ecac9766be6c;p=qemu-gpiodev%2Flibgpiod.git bindings: python: fix a memory leak in error path We need to decref the iter object in Line.set_values() if the conversion from python to C unsigned integer fails. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c index 88d90bf..3c4c254 100644 --- a/bindings/python/gpiodmodule.c +++ b/bindings/python/gpiodmodule.c @@ -1020,8 +1020,10 @@ static PyObject *gpiod_LineBulk_set_values(gpiod_LineBulkObject *self, val = PyLong_AsLong(next); Py_DECREF(next); - if (PyErr_Occurred()) + if (PyErr_Occurred()) { + Py_DECREF(iter); return NULL; + } vals[i] = (int)val; }