Browse Source

ra144: check buffer size before requesting a buffer

Return an error on incomplete frames.
tags/n2.0
Janne Grunau 12 years ago
parent
commit
684e3d2e1c
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      libavcodec/ra144dec.c

+ 7
- 6
libavcodec/ra144dec.c View File

@@ -76,6 +76,13 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *data,
RA144Context *ractx = avctx->priv_data;
GetBitContext gb;

if (buf_size < FRAMESIZE) {
av_log(avctx, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", buf_size);
*got_frame_ptr = 0;
return AVERROR_INVALIDDATA;
}

/* get output buffer */
frame->nb_samples = NBLOCKS * BLOCKSIZE;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
@@ -84,12 +91,6 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *data,
}
samples = (int16_t *)frame->data[0];

if(buf_size < FRAMESIZE) {
av_log(avctx, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", buf_size);
*got_frame_ptr = 0;
return buf_size;
}
init_get_bits(&gb, buf, FRAMESIZE * 8);

for (i = 0; i < LPC_ORDER; i++)


Loading…
Cancel
Save