changeset 6442:28e45bf84973 libavcodec

Prevent segfault due to reading over the end of the input buffer.
author michael
date Tue, 04 Mar 2008 21:39:21 +0000
parents 0cc3651e0bb2
children e3adb7e96812
files apedec.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/apedec.c	Tue Mar 04 18:38:32 2008 +0000
+++ b/apedec.c	Tue Mar 04 21:39:21 2008 +0000
@@ -256,7 +256,10 @@
 static inline void range_dec_normalize(APEContext * ctx)
 {
     while (ctx->rc.range <= BOTTOM_VALUE) {
-        ctx->rc.buffer = (ctx->rc.buffer << 8) | bytestream_get_byte(&ctx->ptr);
+        ctx->rc.buffer <<= 8;
+        if(ctx->ptr < ctx->data_end)
+            ctx->rc.buffer += *ctx->ptr;
+        ctx->ptr++;
         ctx->rc.low    = (ctx->rc.low << 8)    | ((ctx->rc.buffer >> 1) & 0xFF);
         ctx->rc.range  <<= 8;
     }