From e2768fbcdeba97d10c2beaea709412e6fb8b047d Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Tue, 19 Nov 2019 22:32:25 +0100 Subject: Fix multiple PyObject_SetAttrString() related leaks. This fixes bug #1374. --- instance.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'instance.c') diff --git a/instance.c b/instance.c index 52fb43b..85ff37e 100644 --- a/instance.c +++ b/instance.c @@ -140,6 +140,7 @@ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di, Py_DECREF(py_di_options); py_di_options = PyDict_New(); PyObject_SetAttrString(di->py_inst, "options", py_di_options); + Py_DECREF(py_di_options); for (l = di->decoder->options; l; l = l->next) { sdo = l->data; @@ -675,7 +676,7 @@ SRD_API int srd_inst_initial_pins_set_all(struct srd_decoder_inst *di, GArray *i /** @private */ SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di) { - PyObject *py_res; + PyObject *py_res, *py_samplenum; GSList *l; struct srd_decoder_inst *next_di; int ret; @@ -695,7 +696,9 @@ SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di) Py_DecRef(py_res); /* Set self.samplenum to 0. */ - PyObject_SetAttrString(di->py_inst, "samplenum", PyLong_FromLong(0)); + py_samplenum = PyLong_FromLong(0); + PyObject_SetAttrString(di->py_inst, "samplenum", py_samplenum); + Py_DECREF(py_samplenum); /* Set self.matched to None. */ PyObject_SetAttrString(di->py_inst, "matched", Py_None); -- cgit v1.2.3-70-g09d2