summaryrefslogtreecommitdiff
path: root/type_decoder.c
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2018-05-09 01:31:10 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2018-05-09 01:33:10 +0200
commit287e2788a726732e5f29eb3f5f4fe9d68fac4d05 (patch)
treea000ada8b2c754866d9f36d2fe6301aa6cff639b /type_decoder.c
parentc1b2bbc11c5d44f9073d14485e750b9a75389d1f (diff)
downloadlibsigrokdecode-287e2788a726732e5f29eb3f5f4fe9d68fac4d05.tar.gz
libsigrokdecode-287e2788a726732e5f29eb3f5f4fe9d68fac4d05.zip
type_decoder: Fixup memory leak in Decoder.put() (meta, python)
This fixes parts of bug #329.
Diffstat (limited to 'type_decoder.c')
-rw-r--r--type_decoder.c16
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;