summaryrefslogtreecommitdiff
path: root/decoder.c
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2012-01-30 01:22:27 +0100
committerBert Vermeulen <bert@biot.com>2012-01-30 01:22:27 +0100
commitad022d94ef9a32428fe44710e7eff311991fd9e6 (patch)
treea2acbf8c58efc60334ec5e4eb7a295003b206214 /decoder.c
parent1063646c74946527c6e8d23790f6fd8501f5665c (diff)
downloadlibsigrokdecode-ad022d94ef9a32428fe44710e7eff311991fd9e6.tar.gz
libsigrokdecode-ad022d94ef9a32428fe44710e7eff311991fd9e6.zip
srd: clear objects after final decref, so it doesn't happen twice
Diffstat (limited to 'decoder.c')
-rw-r--r--decoder.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/decoder.c b/decoder.c
index 593f259..7480656 100644
--- a/decoder.c
+++ b/decoder.c
@@ -173,7 +173,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
"a subclass of sigrokdecode.Decoder.", name);
goto err_out;
}
- Py_DecRef(py_basedec);
+ Py_CLEAR(py_basedec);
/* Check for a proper start() method. */
if (!PyObject_HasAttrString(d->py_dec, "start")) {
@@ -187,7 +187,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
"is not a method.", name);
goto err_out;
}
- Py_DecRef(py_method);
+ Py_CLEAR(py_method);
/* Check for a proper decode() method. */
if (!PyObject_HasAttrString(d->py_dec, "decode")) {
@@ -201,7 +201,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
"is not a method.", name);
goto err_out;
}
- Py_DecRef(py_method);
+ Py_CLEAR(py_method);
/* If present, options must be a dictionary. */
if (PyObject_HasAttrString(d->py_dec, "options")) {
@@ -209,6 +209,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
if (!PyDict_Check(py_attr)) {
srd_err("Protocol decoder %s options attribute is not "
"a dictionary.", d->name);
+ Py_DecRef(py_attr);
goto err_out;
}
Py_DecRef(py_attr);