summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2021-03-07 07:03:18 +0100
committerGerhard Sittig <gerhard.sittig@gmx.net>2021-03-07 07:03:18 +0100
commit234cbf50152b7e007322c62ed6190ae6bff30a92 (patch)
tree48d7fe0f75ae63421a76e7118ba3112081a5935c
parent2ee740fd9e5197bc9951a0c92e35947203c1b620 (diff)
downloadlibsigrokdecode-234cbf50152b7e007322c62ed6190ae6bff30a92.tar.gz
libsigrokdecode-234cbf50152b7e007322c62ed6190ae6bff30a92.zip
decoder: increment Python object reference for .has_channel() result
This fixes bug #1671. Reported-By: Ivan Wick
-rw-r--r--type_decoder.c5
1 files changed, 4 insertions, 1 deletions
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);