aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/fraps.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-01-31 11:30:34 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-02-01 14:37:47 -0500
commitf54ae2f8e7c905d863b2e96b1d5df3f1b9aa5f30 (patch)
tree020addcf14fbc609c3153d387e99cec7d70e91c7 /libavcodec/fraps.c
parent0880503fbbd68bf6b1352488944020e3ec35c2e4 (diff)
downloadffmpeg-f54ae2f8e7c905d863b2e96b1d5df3f1b9aa5f30.tar.gz
fraps: Use av_fast_padded_malloc() instead of av_realloc()
Ensures alignment and avoids using uninitialized data. Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
Diffstat (limited to 'libavcodec/fraps.c')
-rw-r--r--libavcodec/fraps.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index 1444eda979..5f5e55e8ff 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -46,6 +46,7 @@ typedef struct FrapsContext{
AVCodecContext *avctx;
AVFrame frame;
uint8_t *tmpbuf;
+ int tmpbuf_size;
DSPContext dsp;
} FrapsContext;
@@ -276,7 +277,10 @@ static int decode_frame(AVCodecContext *avctx,
offs[planes] = buf_size;
for(i = 0; i < planes; i++){
is_chroma = !!i;
- s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE);
+ av_fast_padded_malloc(&s->tmpbuf, &s->tmpbuf_size,
+ offs[i + 1] - offs[i] - 1024);
+ if (!s->tmpbuf)
+ return AVERROR(ENOMEM);
if(fraps2_decode_plane(s, f->data[i], f->linesize[i], avctx->width >> is_chroma,
avctx->height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);
@@ -318,7 +322,10 @@ static int decode_frame(AVCodecContext *avctx,
}
offs[planes] = buf_size;
for(i = 0; i < planes; i++){
- s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE);
+ av_fast_padded_malloc(&s->tmpbuf, &s->tmpbuf_size,
+ offs[i + 1] - offs[i] - 1024);
+ if (!s->tmpbuf)
+ return AVERROR(ENOMEM);
if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0],
avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);