]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Fix a bug just introduced into the basic stuffing function. 344/head
authorMike Brady <mikebrady@eircom.net>
Sat, 16 Jul 2016 13:24:34 +0000 (14:24 +0100)
committerMike Brady <mikebrady@eircom.net>
Sat, 16 Jul 2016 13:24:34 +0000 (14:24 +0100)
player.c

index bcf84118ee604302b5f90eabb093fd9622f33a60..97eccfb2931bb7db3ce74b8a4d2000feb131a12b 100644 (file)
--- a/player.c
+++ b/player.c
@@ -890,7 +890,11 @@ static int stuff_buffer_basic(short *inptr, int length, short *outptr, int stuff
     }
     
     // if you're removing, i.e. stuff < 0, copy that much less over. If you're adding, do all the rest.
-    for (i = stuffsamp; i < (stuff>0) ? length : length+stuff; i++) {
+    int remainder = length;
+    if (stuff<0)
+      remainder = remainder+stuff; // don't run over the correct end of the output buffer
+
+    for (i = stuffsamp; i < remainder; i++) {
       *outptr++ = dithered_vol(*inptr++);
       *outptr++ = dithered_vol(*inptr++);
     }