]> sigrok.org Git - libsigrok.git/blobdiff - src/output/csv.c
output/csv: get proper index for input channels
[libsigrok.git] / src / output / csv.c
index f3e6e335e73907bc4927ddbee755d0bfadbb5a1d..831208dc6bf367f40a7d088cb7b4360dd56b0076 100644 (file)
@@ -380,7 +380,7 @@ static void process_logic(struct context *ctx,
                if (ctx->channels[j].ch->type == SR_CHANNEL_LOGIC) {
                        for (i = 0; i < num_samples; i++) {
                                sample = logic->data + i * logic->unitsize;
-                               idx = ctx->channels[ch].ch->index;
+                               idx = ctx->channels[j].ch->index;
                                if (ctx->label_do && !ctx->label_names)
                                        ctx->channels[j].label = "logic";
                                ctx->logic_samples[i * ctx->num_logic_channels + ch] = sample[idx / 8] & (1 << (idx % 8));
@@ -608,6 +608,7 @@ static int cleanup(struct sr_output *o)
                g_free((gpointer)ctx->frame);
                g_free((gpointer)ctx->comment);
                g_free((gpointer)ctx->gnuplot);
+               g_free((gpointer)ctx->value);
                g_free(ctx->previous_sample);
                g_free(ctx->channels);
                g_free(o->priv);