diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-04-12 13:17:37 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-04-12 13:17:37 +0000 |
commit | 238ef6dadd13b9a867eaa7382bdba751e25c40b9 (patch) | |
tree | ac0228289581351403ee3f1d9ad187919d498fbb /libavcodec/4xm.c | |
parent | 9bf993a5b5f8bf10c590d83c795467606f92cf6e (diff) | |
download | ffmpeg-238ef6dadd13b9a867eaa7382bdba751e25c40b9.tar.gz |
Add a av_fast_malloc function and replace several uses of av_fast_realloc,
thus avoiding potential memleaks and pointless memcpys.
Originally committed as revision 18470 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/4xm.c')
-rw-r--r-- | libavcodec/4xm.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 400374287b..8f6ec3a00e 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -378,7 +378,9 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length){ return -1; } - f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!f->bitstream_buffer) + return AVERROR(ENOMEM); f->dsp.bswap_buf(f->bitstream_buffer, (const uint32_t*)(buf + extra), bitstream_size/4); init_get_bits(&f->gb, f->bitstream_buffer, 8*bitstream_size); @@ -656,7 +658,9 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){ prestream_size= length + buf - prestream; - f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!f->bitstream_buffer) + return AVERROR(ENOMEM); f->dsp.bswap_buf(f->bitstream_buffer, (const uint32_t*)prestream, prestream_size/4); init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size); |