From: Gerhard Sittig Date: Sun, 7 Mar 2021 06:03:18 +0000 (+0100) Subject: decoder: increment Python object reference for .has_channel() result X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=234cbf50152b7e007322c62ed6190ae6bff30a92;p=libsigrokdecode.git decoder: increment Python object reference for .has_channel() result This fixes bug #1671. Reported-By: Ivan Wick --- 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);