]> sigrok.org Git - libsigrok.git/commitdiff
input/vcd: fix a divide by zero bug in the analog-only case
authorGerhard Sittig <redacted>
Thu, 22 Oct 2020 17:27:06 +0000 (19:27 +0200)
committerGerhard Sittig <redacted>
Thu, 22 Oct 2020 17:29:58 +0000 (19:29 +0200)
When the input data exclusively contained analog data, then creation of
the submit buffer for logic data caused a division by zero. Fix the
create_feed() routine.

src/input/vcd.c

index fb25f10aae0a9c667378e973ffc82b0128f2c064..4e0310bac67e4e55f7e56f6a124812d13dbfb3aa 100644 (file)
@@ -1096,9 +1096,11 @@ static void create_feeds(const struct sr_input *in)
        inc = in->priv;
 
        /* Create one feed for logic data. */
-       inc->unit_size = (inc->logic_count + 7) / 8;
-       inc->feed_logic = feed_queue_logic_alloc(in->sdi,
-               CHUNK_SIZE / inc->unit_size, inc->unit_size);
+       if (inc->logic_count) {
+               inc->unit_size = (inc->logic_count + 7) / 8;
+               inc->feed_logic = feed_queue_logic_alloc(in->sdi,
+                       CHUNK_SIZE / inc->unit_size, inc->unit_size);
+       }
 
        /* Create one feed per analog channel. */
        for (l = inc->channels; l; l = l->next) {