From: Bartosz Golaszewski Date: Mon, 14 May 2018 09:18:18 +0000 (+0200) Subject: bindings: python: fix a memory leak in gpiod_Line_event_wait() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=15a623a7d29014e9c03f37be2ba45a2a7e31971f;p=qemu-gpiodev%2Flibgpiod.git 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 --- 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; }