From: Gerhard Sittig Date: Mon, 28 Jun 2021 05:34:23 +0000 (+0200) Subject: hp-3478a: avoid NULL dereference in config API routines X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=020df861e0eb70dd39944d861885210ca7e7cc2a;p=libsigrok.git hp-3478a: avoid NULL dereference in config API routines The 'sdi' parameter to config API calls can be NULL. Only dereference after checking its validity. Reported-By: Alexandre Ferreira --- diff --git a/src/hardware/hp-3478a/api.c b/src/hardware/hp-3478a/api.c index cc5d4cb7..f9419a6e 100644 --- a/src/hardware/hp-3478a/api.c +++ b/src/hardware/hp-3478a/api.c @@ -176,7 +176,7 @@ static int config_get(uint32_t key, GVariant **data, (void)cg; - devc = sdi->priv; + devc = sdi ? sdi->priv : NULL; switch (key) { case SR_CONF_LIMIT_SAMPLES: @@ -231,7 +231,7 @@ static int config_set(uint32_t key, GVariant *data, (void)cg; - devc = sdi->priv; + devc = sdi ? sdi->priv : NULL; switch (key) { case SR_CONF_LIMIT_SAMPLES: @@ -278,7 +278,7 @@ static int config_list(uint32_t key, GVariant **data, GVariant *gvar, *arr[2]; GVariantBuilder gvb; - devc = sdi->priv; + devc = sdi ? sdi->priv : NULL; switch (key) { case SR_CONF_SCAN_OPTIONS: