From: Mike Walters Date: Sun, 14 Nov 2021 22:03:01 +0000 (+0000) Subject: kingst-la2016: handle sdi==NULL in config_list X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=fb28e72dfdea0d985e03795f1f058aa4621e7e55 kingst-la2016: handle sdi==NULL in config_list The hardware driver API specifies that the sdi argument to config_list is optional and can be NULL. This change handles that case, instead of dereferencing without a check. --- diff --git a/src/hardware/kingst-la2016/api.c b/src/hardware/kingst-la2016/api.c index 1b1b425a..216869ed 100644 --- a/src/hardware/kingst-la2016/api.c +++ b/src/hardware/kingst-la2016/api.c @@ -504,13 +504,14 @@ static int config_list(uint32_t key, GVariant **data, { struct dev_context *devc; - devc = sdi->priv; - switch (key) { case SR_CONF_SCAN_OPTIONS: case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_SAMPLERATE: + if (!sdi) + return SR_ERR_ARG; + devc = sdi->priv; if (devc->max_samplerate == SR_MHZ(200)) { *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates_la2016)); }