From: Bartosz Golaszewski Date: Sun, 13 May 2018 21:25:06 +0000 (+0200) Subject: bindings: python: fix a memory leak in Line.set_value() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=27fec345ca2597f16b1be4962d4a0794b64cb45f;p=qemu-gpiodev%2Flibgpiod.git bindings: python: fix a memory leak in Line.set_value() We're not collecting the bulk object we're creating in this method. Add Py_DECREF() where needed. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c index 9248616..0aecb24 100644 --- a/bindings/python/gpiodmodule.c +++ b/bindings/python/gpiodmodule.c @@ -385,10 +385,13 @@ static PyObject *gpiod_Line_set_value(gpiod_LineObject *self, PyObject *args) return NULL; vals = Py_BuildValue("((O))", val); - if (!vals) + if (!vals) { + Py_DECREF(bulk_obj); return NULL; + } ret = gpiod_LineBulk_set_values(bulk_obj, vals); + Py_DECREF(bulk_obj); Py_DECREF(vals); return ret;