]> sigrok.org Git - libsigrok.git/commitdiff
hantek-6xxx: fix potential NULL dereference
authorGerhard Sittig <redacted>
Fri, 9 Feb 2018 18:03:06 +0000 (19:03 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:37:39 +0000 (21:37 +0100)
Check pointers' validity before dereferencing.

This was reported by clang's scan-build.

src/hardware/hantek-6xxx/api.c

index 4e64808932e5af1d2e189ee14d1fa069cf58bf38..01cba5669b920ca601a1bafdf5cfd6e45420f85a 100644 (file)
@@ -460,6 +460,8 @@ static int config_list(uint32_t key, GVariant **data,
                        *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
                        break;
                case SR_CONF_COUPLING:
+                       if (!devc)
+                               return SR_ERR_ARG;
                        *data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size);
                        break;
                case SR_CONF_VDIV: