Commit 998fc04b authored by Justin Ruggles's avatar Justin Ruggles Committed by Michael Niedermayer
Browse files

apedec: use unsigned int for 'nblocks' and make sure that it's within int range

Signed-off-by: default avatarMichael Niedermayer <michaelni@gmx.at>
parent 43fa5bf5
No related merge requests found
Showing with 4 additions and 3 deletions
+4 -3
......@@ -802,7 +802,7 @@ static int ape_decode_frame(AVCodecContext * avctx,
int buf_size = avpkt->size;
APEContext *s = avctx->priv_data;
int16_t *samples = data;
int nblocks;
uint32_t nblocks;
int i, n;
int blockstodecode;
int bytes_used;
......@@ -838,9 +838,10 @@ static int ape_decode_frame(AVCodecContext * avctx,
s->currentframeblocks = nblocks;
buf += 4;
if (s->samples <= 0) {
if (!nblocks || nblocks > INT_MAX) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
*data_size = 0;
return buf_size;
return AVERROR_INVALIDDATA;
}
memset(s->decoded0, 0, sizeof(s->decoded0));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment