From 234cbf50152b7e007322c62ed6190ae6bff30a92 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sun, 7 Mar 2021 07:03:18 +0100 Subject: decoder: increment Python object reference for .has_channel() result This fixes bug #1671. Reported-By: Ivan Wick --- type_decoder.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/type_decoder.c b/type_decoder.c index 9508183..b57b606 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -1100,6 +1100,7 @@ static PyObject *Decoder_has_channel(PyObject *self, PyObject *args) int idx, count; struct srd_decoder_inst *di; PyGILState_STATE gstate; + PyObject *bool_ret; if (!self || !args) return NULL; @@ -1130,7 +1131,9 @@ static PyObject *Decoder_has_channel(PyObject *self, PyObject *args) PyGILState_Release(gstate); - return (di->dec_channelmap[idx] == -1) ? Py_False : Py_True; + bool_ret = (di->dec_channelmap[idx] == -1) ? Py_False : Py_True; + Py_INCREF(bool_ret); + return bool_ret; err: PyGILState_Release(gstate); -- cgit v1.2.3-70-g09d2