changeset 13336:55174e3d2917

Index must be positive to prevent endless loop on bad data Based on an idea by iive
author rtognimp
date Tue, 14 Sep 2004 21:02:19 +0000
parents 6c002b4462ae
children c2cd3374a1cb
files mp3lib/layer2.c
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mp3lib/layer2.c	Tue Sep 14 20:43:39 2004 +0000
+++ b/mp3lib/layer2.c	Tue Sep 14 21:02:19 2004 +0000
@@ -80,12 +80,12 @@
     bita = bit_alloc;
     if(stereo)
     {
-      for (i=jsbound;i;i--,alloc1+=(1<<step))
+      for (i=jsbound;i>0;i--,alloc1+=(1<<step))
       {
         *bita++ = (char) getbits(step=alloc1->bits);
         *bita++ = (char) getbits(step);
       }
-      for (i=sblimit-jsbound;i;i--,alloc1+=(1<<step))
+      for (i=sblimit-jsbound;i>0;i--,alloc1+=(1<<step))
       {
         bita[0] = (char) getbits(step=alloc1->bits);
         bita[1] = bita[0];
@@ -93,24 +93,24 @@
       }
       bita = bit_alloc;
       scfsi=scfsi_buf;
-      for (i=sblimit2;i;i--)
+      for (i=sblimit2;i>0;i--)
         if (*bita++)
           *scfsi++ = (char) getbits_fast(2);
     }
     else /* mono */
     {
-      for (i=sblimit;i;i--,alloc1+=(1<<step))
+      for (i=sblimit;i>0;i--,alloc1+=(1<<step))
         *bita++ = (char) getbits(step=alloc1->bits);
       bita = bit_alloc;
       scfsi=scfsi_buf;
-      for (i=sblimit;i;i--)
+      for (i=sblimit;i>0;i--)
         if (*bita++)
           *scfsi++ = (char) getbits_fast(2);
     }
 
     bita = bit_alloc;
     scfsi=scfsi_buf;
-    for (i=sblimit2;i;i--) 
+    for (i=sblimit2;i>0;i--) 
       if (*bita++)
         switch (*scfsi++) 
         {