From 7ddb1a5fe50d05e4f14348faa3234e9c2cac2dc5 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Tue, 27 Sep 2016 09:01:21 +0200 Subject: [PATCH] Don't rely on the resampling code to calculate the number of samples to process, as it may produce one extra sample (to handle accumulation of fractional samples), which would cause access to one sample past the end of the buffer and crash aucat. Fix this by limiting the number of samples processed to a single block. Found by and help from Michael W. Bombardieri . Thanks. --- aucat/aucat.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/aucat/aucat.c b/aucat/aucat.c index 429c444..a3aa212 100644 --- a/aucat/aucat.c +++ b/aucat/aucat.c @@ -532,6 +532,8 @@ slot_mix_badd(struct slot *s, adata_t *odata) while (otodo > 0) { idata = (adata_t *)abuf_rgetblk(&s->buf, &len); icnt = len / s->bpf; + if (icnt > s->round) + icnt = s->round; ocnt = otodo; slot_getcnt(s, &icnt, &ocnt); if (icnt == 0) @@ -606,6 +608,8 @@ slot_sub_bcopy(struct slot *s, adata_t *idata, int itodo) while (itodo > 0) { odata = (adata_t *)abuf_wgetblk(&s->buf, &len); ocnt = len / s->bpf; + if (ocnt > s->round) + ocnt = s->round; icnt = itodo; slot_getcnt(s, &icnt, &ocnt); if (ocnt == 0)