diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-01-18 21:23:22 +0100 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-01-18 22:04:14 +0100 |
commit | e8b060f7e72f76e7d9e62ad4733201770cbe2bb5 (patch) | |
tree | 32ac21b9384eab9ac0f10674e30936af1f6de161 /libavcodec/truemotion2.c | |
parent | 126b04196e2a4af69644464b44d4b237185eff8e (diff) | |
download | ffmpeg-streaming-e8b060f7e72f76e7d9e62ad4733201770cbe2bb5.zip ffmpeg-streaming-e8b060f7e72f76e7d9e62ad4733201770cbe2bb5.tar.gz |
Use av_fast_padded_malloc in mimic and truemotion2 decoders.
Fixes use of uninitialized data errors under valgrind.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/truemotion2.c')
-rw-r--r-- | libavcodec/truemotion2.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index 5673834..e68a687 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -44,6 +44,9 @@ typedef struct TM2Context{ GetBitContext gb; DSPContext dsp; + uint8_t *buffer; + int buffer_size; + /* TM2 streams */ int *tokens[TM2_NUM_STREAMS]; int tok_lens[TM2_NUM_STREAMS]; @@ -766,10 +769,9 @@ static int decode_frame(AVCodecContext *avctx, TM2Context * const l = avctx->priv_data; AVFrame * const p= (AVFrame*)&l->pic; int i, skip, t; - uint8_t *swbuf; - swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); - if(!swbuf){ + av_fast_padded_malloc(&l->buffer, &l->buffer_size, buf_size); + if(!l->buffer){ av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); return -1; } @@ -777,22 +779,19 @@ static int decode_frame(AVCodecContext *avctx, p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if(avctx->reget_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - av_free(swbuf); return -1; } - l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2); - skip = tm2_read_header(l, swbuf); + l->dsp.bswap_buf((uint32_t*)l->buffer, (const uint32_t*)buf, buf_size >> 2); + skip = tm2_read_header(l, l->buffer); if(skip == -1){ - av_free(swbuf); return -1; } for(i = 0; i < TM2_NUM_STREAMS; i++){ - t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i], buf_size); + t = tm2_read_stream(l, l->buffer + skip, tm2_stream_order[i], buf_size); if(t == -1){ - av_free(swbuf); return -1; } skip += t; @@ -806,7 +805,6 @@ static int decode_frame(AVCodecContext *avctx, l->cur = !l->cur; *data_size = sizeof(AVFrame); *(AVFrame*)data = l->pic; - av_free(swbuf); return buf_size; } @@ -863,6 +861,8 @@ static av_cold int decode_end(AVCodecContext *avctx){ av_free(l->U2); av_free(l->V2); } + av_freep(&l->buffer); + l->buffer_size = 0; if (pic->data[0]) avctx->release_buffer(avctx, pic); |