From 27fec345ca2597f16b1be4962d4a0794b64cb45f Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Sun, 13 May 2018 23:25:06 +0200 Subject: [PATCH] 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 --- bindings/python/gpiodmodule.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; -- 2.30.2