diff options
-rw-r--r-- | type_decoder.c | 16 |
1 files changed, 16 insertions, 0 deletions
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; |