X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fopenbench-logic-sniffer%2Fapi.c;h=b99d8e72125545258214a1513389482ef5fa116c;hb=fd830beb6751a966a0f12a9ca48a8550bbe5bbba;hp=bcc41ed2522d200b7516c943844336f4b8c7c437;hpb=3f239f0803b9fbc073dd7abe9fc7b2a0c606fbb6;p=libsigrok.git diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index bcc41ed2..b99d8e72 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -399,6 +399,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, if (devc->channel_mask & (0xff << (i * 8))) num_channels++; } + if (num_channels == 0) { + /* This can happen, but shouldn't cause too much drama. + * However we can't continue because the code below would + * divide by zero. */ + break; + } grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES); grange[1] = g_variant_new_uint64(devc->max_samples / num_channels); *data = g_variant_new_tuple(grange, 2);