aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vqavideo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-17 23:16:05 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-17 23:16:05 +0100
commit967bdb8572f27b9891fe7bd9b8489146a906633d (patch)
tree61b486be897a4503f71e2ecc7734f16930dc1a94 /libavcodec/vqavideo.c
parent219a6fb61cb9e6f534f20dc3313442f89b0ffd42 (diff)
parent6ca3b248e21fc48418c4221fc92c2eecaf07cb9b (diff)
downloadffmpeg-967bdb8572f27b9891fe7bd9b8489146a906633d.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: resample: allocate a large enough output buffer fate: fix enc_dec_pcm tests with remote target wmaenc: remove bit-exact hack FATE: remove WMA acodec tests FATE: add WMAv1 and WMAv2 encode/decode tests with fuzzy comparison FATE: add AC-3 and E-AC-3 encode/decode tests with fuzzy comparison qtrle: Use bytestream2 functions to prevent buffer overreads. vqavideo: check malloc return values x11grab: fix a memory leak exposed by valgrind threads: fix old frames returned after avcodec_flush_buffers() MPV: always mark dummy frames as reference h264: fix deadlocks on incomplete reference frame decoding. mpeg4: report frame decoding completion at ff_MPV_frame_end(). mimic: don't use self as reference, and report completion at end of decode(). Conflicts: libavcodec/h264.c libavcodec/qtrle.c libavcodec/resample.c libavcodec/vqavideo.c libavdevice/x11grab.c tests/ref/seek/wmav1_asf tests/ref/seek/wmav2_asf Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vqavideo.c')
-rw-r--r--libavcodec/vqavideo.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index ae99c6d9c1..ba70a11c59 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -162,7 +162,18 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
/* allocate codebooks */
s->codebook_size = MAX_CODEBOOK_SIZE;
s->codebook = av_malloc(s->codebook_size);
+ if (!s->codebook)
+ goto fail;
s->next_codebook_buffer = av_malloc(s->codebook_size);
+ if (!s->next_codebook_buffer)
+ goto fail;
+
+ /* allocate decode buffer */
+ s->decode_buffer_size = (s->width / s->vector_width) *
+ (s->height / s->vector_height) * 2;
+ s->decode_buffer = av_malloc(s->decode_buffer_size);
+ if (!s->decode_buffer)
+ goto fail;
/* initialize the solid-color vectors */
if (s->vector_height == 4) {
@@ -178,15 +189,15 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
}
s->next_codebook_buffer_index = 0;
- /* allocate decode buffer */
- s->decode_buffer_size = (s->width / s->vector_width) *
- (s->height / s->vector_height) * 2;
- s->decode_buffer = av_malloc(s->decode_buffer_size);
-
avcodec_get_frame_defaults(&s->frame);
s->frame.data[0] = NULL;
return 0;
+fail:
+ av_freep(&s->codebook);
+ av_freep(&s->next_codebook_buffer);
+ av_freep(&s->decode_buffer);
+ return AVERROR(ENOMEM);
}
#define CHECK_COUNT() \
@@ -606,9 +617,9 @@ static av_cold int vqa_decode_end(AVCodecContext *avctx)
{
VqaContext *s = avctx->priv_data;
- av_free(s->codebook);
- av_free(s->next_codebook_buffer);
- av_free(s->decode_buffer);
+ av_freep(&s->codebook);
+ av_freep(&s->next_codebook_buffer);
+ av_freep(&s->decode_buffer);
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);