summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2014-05-04 23:46:21 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2014-05-04 23:58:03 +0200
commit5c0c9cb3a78be20d98f81cff1405bbf2c927384e (patch)
tree44282f8bb65937bd57b177281efd3bf33ed8394d
parent5dec4b91cb72c49453134fb3ba5c9930895825f2 (diff)
downloadlibsigrokdecode-5c0c9cb3a78be20d98f81cff1405bbf2c927384e.tar.gz
libsigrokdecode-5c0c9cb3a78be20d98f81cff1405bbf2c927384e.zip
Only load and use PDs of API version 2.
Decoders that implement any other PD API version are per definition not compatible and cannot work with this library version.
-rw-r--r--decoder.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/decoder.c b/decoder.c
index ff6e7ac..71e9122 100644
--- a/decoder.c
+++ b/decoder.c
@@ -366,6 +366,17 @@ SRD_API int srd_decoder_load(const char *module_name)
}
Py_CLEAR(py_basedec);
+ /*
+ * Check that thіs decoder has the correct PD API version.
+ * PDs of different API versions are incompatible and cannot work.
+ */
+ py_long = PyObject_GetAttrString(d->py_dec, "api_version");
+ if (PyLong_AsLong(py_long) != 2) {
+ srd_err("Only PDs of API version 2 are supported.");
+ goto err_out;
+ }
+ Py_CLEAR(py_long);
+
/* Check for a proper start() method. */
if (!PyObject_HasAttrString(d->py_dec, "start")) {
srd_err("Protocol decoder %s has no start() method Decoder "