diff options
author | Bert Vermeulen <bert@biot.com> | 2012-01-21 19:45:04 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2012-01-21 19:45:04 +0100 |
commit | 19a90bab1b8d88c173ce29f8243747740d280164 (patch) | |
tree | 4ce7aeb1199e93b50fc290462add26e48ee624b7 | |
parent | 4244f8252706c5715a5598c51914f4f8d20c5e84 (diff) | |
download | libsigrokdecode-19a90bab1b8d88c173ce29f8243747740d280164.tar.gz libsigrokdecode-19a90bab1b8d88c173ce29f8243747740d280164.zip |
srd: better check for PDs with no defined probes
-rw-r--r-- | controller.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/controller.c b/controller.c index 3292603..a093102 100644 --- a/controller.c +++ b/controller.c @@ -297,8 +297,7 @@ int srd_instance_set_probes(struct srd_decoder_instance *di, /* No probes provided. */ return SRD_OK; - if(!PyObject_HasAttrString(di->decoder->py_dec, "probes") - && !PyObject_HasAttrString(di->decoder->py_dec, "extra_probes")) { + if(di->dec_num_probes == 0) { /* Decoder has no probes. */ srd_err("Protocol decoder %s has no probes to define.", di->decoder->name); @@ -374,13 +373,15 @@ struct srd_decoder_instance *srd_instance_new(const char *decoder_id, */ di->dec_num_probes = g_slist_length(di->decoder->probes) + g_slist_length(di->decoder->extra_probes); - if (!(di->dec_probemap = g_try_malloc(sizeof(int) * di->dec_num_probes))) { - srd_err("Failed to malloc probe map."); - g_free(di); - return NULL; + if (di->dec_num_probes) { + if (!(di->dec_probemap = g_try_malloc(sizeof(int) * di->dec_num_probes))) { + srd_err("Failed to malloc probe map."); + g_free(di); + return NULL; + } + for (i = 0; i < di->dec_num_probes; i++) + di->dec_probemap[i] = i; } - for (i = 0; i < di->dec_num_probes; i++) - di->dec_probemap[i] = i; /* Create a new instance of this decoder class. */ if (!(di->py_instance = PyObject_CallObject(dec->py_dec, NULL))) { |