]> sigrok.org Git - libsigrok.git/commitdiff
output/csv: fix segfault with logic channels
authorWolfram Sang <redacted>
Thu, 11 May 2017 11:51:08 +0000 (13:51 +0200)
committerUwe Hermann <redacted>
Sat, 13 May 2017 20:34:13 +0000 (22:34 +0200)
'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 <redacted>
src/output/csv.c

index 97102f45917482ee002e75caabe33754bcdfc0c3..f3e6e335e73907bc4927ddbee755d0bfadbb5a1d 100644 (file)
@@ -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";