summaryrefslogtreecommitdiff
path: root/instance.c
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2019-11-19 22:32:25 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2019-11-19 22:32:25 +0100
commite2768fbcdeba97d10c2beaea709412e6fb8b047d (patch)
tree77fb47c104cf134354861eef5827631c353668d6 /instance.c
parent8c5c361a0e312fd8dab699c322b2e4db3c598019 (diff)
downloadlibsigrokdecode-e2768fbcdeba97d10c2beaea709412e6fb8b047d.tar.gz
libsigrokdecode-e2768fbcdeba97d10c2beaea709412e6fb8b047d.zip
Fix multiple PyObject_SetAttrString() related leaks.
This fixes bug #1374.
Diffstat (limited to 'instance.c')
-rw-r--r--instance.c7
1 files changed, 5 insertions, 2 deletions
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);