]> sigrok.org Git - libsigrok.git/commitdiff
hp-3478a: avoid NULL dereference in config API routines
authorGerhard Sittig <redacted>
Mon, 28 Jun 2021 05:34:23 +0000 (07:34 +0200)
committerGerhard Sittig <redacted>
Mon, 28 Jun 2021 05:34:23 +0000 (07:34 +0200)
The 'sdi' parameter to config API calls can be NULL. Only dereference
after checking its validity.

Reported-By: Alexandre Ferreira <redacted>
src/hardware/hp-3478a/api.c

index cc5d4cb7a172ccc227a1a4082023d1d50027022a..f9419a6e09ced36fb7625a24990b2a50ae4387e4 100644 (file)
@@ -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: