From: Gerhard Sittig Date: Wed, 31 Aug 2022 15:37:05 +0000 (-0600) Subject: asix-sigma: check sdi before dereferencing a NULL pointer X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=05a8a5f3c34fab5fbabe241dacd929616ebae88f asix-sigma: check sdi before dereferencing a NULL pointer The asix-sigma config_list() routine unconditionally dereferenced the 'sdi' pointer, which could be NULL. Properly check before dereferencing. This issue was introduced in commit eabf9ca630f4. How to reproduce: $ sigrok-cli -d asix-sigma --show Reported-By: Paul Kasemir --- diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index 72da2c14..f1b96bb7 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -401,7 +401,7 @@ static int config_list(uint32_t key, GVariant **data, const char **names; size_t count; - devc = sdi->priv; + devc = sdi ? sdi->priv : NULL; switch (key) { case SR_CONF_SCAN_OPTIONS: case SR_CONF_DEVICE_OPTIONS: @@ -413,6 +413,8 @@ static int config_list(uint32_t key, GVariant **data, *data = sigma_get_samplerates_list(); break; case SR_CONF_EXTERNAL_CLOCK_SOURCE: + if (!devc) + return SR_ERR_ARG; names = (const char **)devc->channel_names; count = g_strv_length(devc->channel_names); *data = g_variant_new_strv(names, count);