]> sigrok.org Git - libsigrok.git/commitdiff
hantek-6xxx: Only list DC coupling once.
authorUwe Hermann <redacted>
Tue, 16 May 2017 23:07:56 +0000 (01:07 +0200)
committerUwe Hermann <redacted>
Tue, 16 May 2017 23:46:50 +0000 (01:46 +0200)
Avoid incorrect indexing and the follow-up segfault.

This fixes bug #822.

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

index c05290be6e9ab460b36813740c13b22a62b8e1c2..08062add77ec07424012d6a6a78d490d23c63b62 100644 (file)
@@ -52,7 +52,7 @@ static const char *channel_names[] = {
 };
 
 static const char *dc_coupling[] = {
-       "DC", "DC",
+       "DC",
 };
 
 static const char *acdc_coupling[] = {
@@ -385,7 +385,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                        *data = g_variant_new("(tt)", vdiv[0], vdiv[1]);
                        break;
                case SR_CONF_COUPLING:
-                       *data = g_variant_new_string(devc->coupling_vals[devc->coupling[ch_idx]]);
+                       *data = g_variant_new_string((devc->coupling[ch_idx] \
+                                       == COUPLING_DC) ? "DC" : "AC");
                        break;
                }
        }