X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Foutput%2Fcsv.c;h=831208dc6bf367f40a7d088cb7b4360dd56b0076;hb=45fcaf2ccad796b4bc4434d81b1d0e23f11a8eae;hp=402ab904454c69cc0669d1152ad1810a6ad4dc8f;hpb=8005151b8783b002f5e07aa9e4e077ea6aed1688;p=libsigrok.git diff --git a/src/output/csv.c b/src/output/csv.c index 402ab904..831208dc 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -378,11 +378,11 @@ static void process_logic(struct context *ctx, for (j = ch = 0; ch < ctx->num_logic_channels; j++) { if (ctx->channels[j].ch->type == SR_CHANNEL_LOGIC) { - for (i = 0; i <= logic->length - logic->unitsize; i += logic->unitsize) { - sample = logic->data + i; - idx = ctx->channels[ch].ch->index; + for (i = 0; i < num_samples; i++) { + sample = logic->data + i * logic->unitsize; + idx = ctx->channels[j].ch->index; if (ctx->label_do && !ctx->label_names) - ctx->channels[i].label = "logic"; + ctx->channels[j].label = "logic"; ctx->logic_samples[i * ctx->num_logic_channels + ch] = sample[idx / 8] & (1 << (idx % 8)); } ch++; @@ -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);