]> sigrok.org Git - libsigrok.git/commitdiff
chronovu-la: avoid NULL pointer dereference
authorGerhard Sittig <redacted>
Thu, 8 Feb 2018 21:44:16 +0000 (22:44 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:34:17 +0000 (21:34 +0100)
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.

src/hardware/chronovu-la/api.c

index 3d19b4f06941ce4b20f51a4b6d63a3d0b387651e..8ca68edbb66645b84946809bc7b407730a7da36b 100644 (file)
@@ -351,12 +351,12 @@ static int config_list(uint32_t key, GVariant **data,
                *data = std_gvar_samplerates(ARRAY_AND_SIZE(devc->samplerates));
                break;
        case SR_CONF_LIMIT_SAMPLES:
-               if (!devc->prof)
+               if (!devc || !devc->prof)
                        return SR_ERR_BUG;
                *data = std_gvar_tuple_u64(0, (devc->prof->model == CHRONOVU_LA8) ? MAX_NUM_SAMPLES : MAX_NUM_SAMPLES / 2);
                break;
        case SR_CONF_TRIGGER_MATCH:
-               if (!devc->prof)
+               if (!devc || !devc->prof)
                        return SR_ERR_BUG;
                *data = std_gvar_array_i32(trigger_matches, devc->prof->num_trigger_matches);
                break;