Commit e8b060f7 authored by Reimar Döffinger's avatar Reimar Döffinger

Use av_fast_padded_malloc in mimic and truemotion2 decoders.

Fixes use of uninitialized data errors under valgrind.
Signed-off-by: 's avatarReimar Döffinger <Reimar.Doeffinger@gmx.de>
parent 126b0419
......@@ -367,8 +367,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
ff_thread_finish_setup(avctx);
av_fast_malloc(&ctx->swap_buf, &ctx->swap_buf_size,
swap_buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
av_fast_padded_malloc(&ctx->swap_buf, &ctx->swap_buf_size, swap_buf_size);
if(!ctx->swap_buf)
return AVERROR(ENOMEM);
......
......@@ -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);
......
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