summaryrefslogtreecommitdiff
path: root/libavcodec/apedec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-10-11 13:34:18 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-28 11:47:28 -0400
commitfd244ae3a068f4f480e967e8e522f69ef6968c69 (patch)
tree445bd6ac43f2aa34de9389a0108c0630a39ad222 /libavcodec/apedec.c
parent89ec474a437770150c048d0db631b0bee4251b8a (diff)
apedec: use unsigned int for offset
avoids implementation-defined unsigned-to-signed conversion and simplifies the bounds checking.
Diffstat (limited to 'libavcodec/apedec.c')
-rw-r--r--libavcodec/apedec.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 4e09871b54..ed9073cf9b 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -813,7 +813,7 @@ static int ape_decode_frame(AVCodecContext *avctx,
APEContext *s = avctx->priv_data;
int16_t *samples = data;
uint32_t nblocks;
- int i, n;
+ int i;
int blockstodecode;
int bytes_used;
@@ -824,6 +824,7 @@ static int ape_decode_frame(AVCodecContext *avctx,
}
if(!s->samples){
+ uint32_t offset;
void *tmp_data = av_realloc(s->data, (buf_size + 3) & ~3);
if (!tmp_data)
return AVERROR(ENOMEM);
@@ -833,13 +834,13 @@ static int ape_decode_frame(AVCodecContext *avctx,
s->data_end = s->data + buf_size;
nblocks = bytestream_get_be32(&s->ptr);
- n = bytestream_get_be32(&s->ptr);
- if(n < 0 || n > 3){
+ offset = bytestream_get_be32(&s->ptr);
+ if (offset > 3) {
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return AVERROR_INVALIDDATA;
}
- s->ptr += n;
+ s->ptr += offset;
if (!nblocks || nblocks > INT_MAX) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);