summaryrefslogtreecommitdiff
path: root/libavcodec/apedec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-10-11 12:49:46 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-28 11:47:27 -0400
commitb7e514575982fd2f5db5ea4f3b466d6dd6a08aa7 (patch)
treebaf3317251d1e3f706c7f73e15c510208a6cbb29 /libavcodec/apedec.c
parent11ca8b2d7486e879926488404b3b79af774f0f2d (diff)
downloadffmpeg-b7e514575982fd2f5db5ea4f3b466d6dd6a08aa7.tar.gz
apedec: do not set s->samples until after validation.
This prevents errors and/or invalid writes in the next decode call due to s->samples still being negative.
Diffstat (limited to 'libavcodec/apedec.c')
-rw-r--r--libavcodec/apedec.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 2041e2b3c5..a741c7d469 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -832,7 +832,7 @@ static int ape_decode_frame(AVCodecContext *avctx,
s->ptr = s->last_ptr = s->data;
s->data_end = s->data + buf_size;
- nblocks = s->samples = bytestream_get_be32(&s->ptr);
+ nblocks = bytestream_get_be32(&s->ptr);
n = bytestream_get_be32(&s->ptr);
if(n < 0 || n > 3){
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
@@ -843,10 +843,11 @@ static int ape_decode_frame(AVCodecContext *avctx,
s->currentframeblocks = nblocks;
buf += 4;
- if (s->samples <= 0) {
+ if (nblocks <= 0) {
*data_size = 0;
return buf_size;
}
+ s->samples = nblocks;
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));