diff cabac.h @ 2116:48d9f86fb047 libavcodec

overread fix
author michael
date Thu, 08 Jul 2004 00:53:21 +0000
parents f65d87bfdd5a
children 1c39d9786efd
line wrap: on
line diff
--- a/cabac.h	Tue Jul 06 12:27:36 2004 +0000
+++ b/cabac.h	Thu Jul 08 00:53:21 2004 +0000
@@ -39,6 +39,7 @@
     uint8_t mps_state[2*64];      ///< transIdxMPS
     const uint8_t *bytestream_start;
     const uint8_t *bytestream;
+    const uint8_t *bytestream_end;
     int bits_left;                ///<
     PutBitContext pb;
 }CABACContext;
@@ -253,7 +254,9 @@
         c->range+= c->range;
         c->low+= c->low;
         if(--c->bits_left == 0){
-            c->low+= *c->bytestream++;
+            if(c->bytestream < c->bytestream_end)
+                c->low+= *c->bytestream;
+            c->bytestream++;
             c->bits_left= 8;
         }
     }
@@ -298,7 +301,9 @@
     c->low += c->low;
 
     if(--c->bits_left == 0){
-        c->low+= *c->bytestream++;
+        if(c->bytestream < c->bytestream_end)
+            c->low+= *c->bytestream;
+        c->bytestream++;
         c->bits_left= 8;
     }