]> sigrok.org Git - libsigrok.git/commitdiff
wav: Don't assume CHUNK_SIZE >= total_samples
authorSoeren Apel <redacted>
Tue, 5 Jun 2018 14:53:59 +0000 (16:53 +0200)
committerSoeren Apel <redacted>
Wed, 6 Jun 2018 20:07:04 +0000 (22:07 +0200)
src/input/wav.c

index b11dcc4860d5a54aae1e0259ada251a3e7741459..66dfce98e84a47f26fcf11827d9072c2e12fad51 100644 (file)
@@ -203,10 +203,11 @@ static void send_chunk(const struct sr_input *in, int offset, int num_samples)
 
        inc = in->priv;
 
+       total_samples = num_samples * inc->num_channels;
+       fdata = g_malloc0(total_samples * sizeof(float));
        s = in->buf->str + offset;
-       fdata = g_malloc0(CHUNK_SIZE * sizeof(float));
        d = (char *)fdata;
-       total_samples = num_samples * inc->num_channels;
+
        for (samplenum = 0; samplenum < total_samples; samplenum++) {
                if (inc->fmt_code == WAVE_FORMAT_PCM_) {
                        switch (inc->unitsize) {