From d3cc09a612a6f8f2bf258bbd33a7dfd2c3a30968 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Thu, 11 May 2017 13:51:08 +0200 Subject: [PATCH] output/csv: fix segfault with logic channels 'i' was iterating in steps of unitsize. However, the destination array was also indexed with it, but it is of u8 type. Let 'i' run bytewise and only multiply with unitsize when we need it. This fixes parts of bug #844. Signed-off-by: Wolfram Sang --- src/output/csv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output/csv.c b/src/output/csv.c index 97102f45..f3e6e335 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -378,8 +378,8 @@ 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; + for (i = 0; i < num_samples; i++) { + sample = logic->data + i * logic->unitsize; idx = ctx->channels[ch].ch->index; if (ctx->label_do && !ctx->label_names) ctx->channels[j].label = "logic";