summaryrefslogtreecommitdiff
path: root/controller.c
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2012-01-23 19:34:23 +0100
committerBert Vermeulen <bert@biot.com>2012-01-23 19:34:23 +0100
commitbe873260307fb879200ace642c15164c39234007 (patch)
treee6bb0433f67f9f3ba76584e8140c18c73850cff4 /controller.c
parent0146063014a7dba729ce2378e30ea9d501ac0ae8 (diff)
downloadlibsigrokdecode-be873260307fb879200ace642c15164c39234007.tar.gz
libsigrokdecode-be873260307fb879200ace642c15164c39234007.zip
srd: deal with invalid probe specifications better
Diffstat (limited to 'controller.c')
-rw-r--r--controller.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/controller.c b/controller.c
index d79c607..845208a 100644
--- a/controller.c
+++ b/controller.c
@@ -296,7 +296,7 @@ int srd_instance_set_probes(struct srd_decoder_instance *di,
GSList *sl;
struct srd_probe *p;
int *new_probemap, new_probenum;
- char *probe_id;
+ char *probe_id, *probenum_str;
if (g_hash_table_size(new_probes) == 0)
/* No probes provided. */
@@ -318,7 +318,14 @@ int srd_instance_set_probes(struct srd_decoder_instance *di,
for (l = g_hash_table_get_keys(new_probes); l; l = l->next) {
probe_id = l->data;
- new_probenum = strtol(g_hash_table_lookup(new_probes, probe_id), NULL, 10);
+ probenum_str = g_hash_table_lookup(new_probes, probe_id);
+ if (!probenum_str) {
+ /* Probe name was specified without a value. */
+ srd_err("No probe number was specified for %s.", probe_id);
+ g_free(new_probemap);
+ return SRD_ERR_ARG;
+ }
+ new_probenum = strtol(probenum_str, NULL, 10);
if (!(sl = g_slist_find_custom(di->decoder->probes, probe_id,
(GCompareFunc)compare_probe_id))) {
/* Fall back on optional probes. */