X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=type_decoder.c;h=aa92c3b22490d9e68813661bbd80c7e7575e89e2;hp=79e9c4924ebd3083605037a0b42b051a53bcf024;hb=287e2788a726732e5f29eb3f5f4fe9d68fac4d05;hpb=c1b2bbc11c5d44f9073d14485e750b9a75389d1f diff --git a/type_decoder.c b/type_decoder.c index 79e9c49..aa92c3b 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -247,6 +247,13 @@ err: return SRD_ERR_PYTHON; } +static void release_meta(GVariant *gvar) +{ + if (!gvar) + return; + g_variant_unref(gvar); +} + static PyObject *Decoder_put(PyObject *self, PyObject *args) { GSList *l; @@ -259,6 +266,8 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) struct srd_pd_callback *cb; PyGILState_STATE gstate; + py_data = NULL; + gstate = PyGILState_Ensure(); if (!(di = srd_inst_find_by_obj(NULL, self))) { @@ -351,6 +360,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS cb->cb(&pdata, cb->cb_data); Py_END_ALLOW_THREADS + release_meta(pdata.data); } break; default: @@ -359,11 +369,17 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) break; } + if (py_data) + Py_DECREF(py_data); + PyGILState_Release(gstate); Py_RETURN_NONE; err: + if (py_data) + Py_DECREF(py_data); + PyGILState_Release(gstate); return NULL;