Make sure to not exceed the ctx->analog_samples[] array bounds. Don't
use the (huge) channel's index in the device's(!) channel list, instead
use the zero-based and dense index into the array of analog samples in
the accumulation buffer, before writing to the external file.
This fixes the segfault reported in bug #1124.
int ret;
size_t num_rcvd_ch, num_have_ch;
size_t idx_have, idx_smpl, idx_rcvd;
int ret;
size_t num_rcvd_ch, num_have_ch;
size_t idx_have, idx_smpl, idx_rcvd;
struct sr_analog_meaning *meaning;
GSList *l;
float *fdata = NULL;
struct sr_analog_meaning *meaning;
GSList *l;
float *fdata = NULL;
sr_warn("Problems converting data to floating point values.");
num_have_ch = ctx->num_analog_channels + ctx->num_logic_channels;
sr_warn("Problems converting data to floating point values.");
num_have_ch = ctx->num_analog_channels + ctx->num_logic_channels;
for (idx_have = 0; idx_have < num_have_ch; idx_have++) {
if (ctx->channels[idx_have].ch->type != SR_CHANNEL_ANALOG)
continue;
for (idx_have = 0; idx_have < num_have_ch; idx_have++) {
if (ctx->channels[idx_have].ch->type != SR_CHANNEL_ANALOG)
continue;
&ctx->channels[idx_have].label);
}
for (idx_smpl = 0; idx_smpl < analog->num_samples; idx_smpl++)
&ctx->channels[idx_have].label);
}
for (idx_smpl = 0; idx_smpl < analog->num_samples; idx_smpl++)
- ctx->analog_samples[idx_smpl * ctx->num_analog_channels + idx_have] = fdata[idx_smpl * num_rcvd_ch + idx_rcvd];
+ ctx->analog_samples[idx_smpl * ctx->num_analog_channels + idx_send] = fdata[idx_smpl * num_rcvd_ch + idx_rcvd];