]> sigrok.org Git - libsigrokdecode.git/commitdiff
decoder: increment Python object reference for .has_channel() result
authorGerhard Sittig <redacted>
Sun, 7 Mar 2021 06:03:18 +0000 (07:03 +0100)
committerGerhard Sittig <redacted>
Sun, 7 Mar 2021 06:03:18 +0000 (07:03 +0100)
This fixes bug #1671.

Reported-By: Ivan Wick
type_decoder.c

index 95081835038388f5b9aef30b0799d3f9c087f941..b57b60655e0056f84b3d55c57b311e8c125e10fd 100644 (file)
@@ -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);