shithub: sox

Download patch

ref: d96b541d0c4a9bfe42413a99e07691e249c2fc42
parent: 2d3823c23c8d5f5dcb05abfc071ecc781e011b7b
author: Ulrich Klauer <ulrich@chirlu.de>
date: Sun Oct 9 19:46:27 EDT 2011

Fix crash in compand effect

The compand effect drain() function overran its output buffer if the
buffer length was not evenly divisible by the number of channels (i.e.
usually, if the number of channels was not a power of two). This was
only triggered if a delay was specified, since otherwise there are no
samples to be drained.

--- a/src/compand.c
+++ b/src/compand.c
@@ -242,7 +242,7 @@
 
   if (l->delay_buf_full == 0)
     l->delay_buf_index = 0;
-  while (done < *osamp && l->delay_buf_cnt > 0)
+  while (done+effp->out_signal.channels <= *osamp && l->delay_buf_cnt > 0)
     for (chan = 0; chan < effp->out_signal.channels; ++chan) {
       int c = l->expectedChannels > 1 ? chan : 0;
       double level_in_lin = l->channels[c].volume;