From 15a623a7d29014e9c03f37be2ba45a2a7e31971f Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 14 May 2018 11:18:18 +0200 Subject: [PATCH] bindings: python: fix a memory leak in gpiod_Line_event_wait() We don't return the object returned from gpiod_LineBulk_event_wait() back to the interpreter. We need to collect it before returning True. Signed-off-by: Bartosz Golaszewski --- bindings/python/gpiodmodule.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c index 0aecb24..02af819 100644 --- a/bindings/python/gpiodmodule.c +++ b/bindings/python/gpiodmodule.c @@ -422,17 +422,20 @@ static PyObject *gpiod_Line_event_wait(gpiod_LineObject *self, PyObject *args, PyObject *kwds) { gpiod_LineBulkObject *bulk_obj; - PyObject *ret; + PyObject *events; bulk_obj = gpiod_LineToLineBulk(self); if (!bulk_obj) return NULL; - ret = gpiod_LineBulk_event_wait(bulk_obj, args, kwds); + events = gpiod_LineBulk_event_wait(bulk_obj, args, kwds); Py_DECREF(bulk_obj); - if (!ret || ret == Py_False) - return ret; + if (!events) + return NULL; + if (events == Py_False) + return Py_False; + Py_DECREF(events); Py_RETURN_TRUE; } -- 2.30.2