diff options
author | Lukasz Marek <lukasz.m.luki2@gmail.com> | 2014-11-24 01:10:49 +0100 |
---|---|---|
committer | Lukasz Marek <lukasz.m.luki2@gmail.com> | 2014-11-24 04:15:24 +0100 |
commit | efe34e87ebf5119bbfabe353f9eb3a99c4c6d266 (patch) | |
tree | 43999e645bd98bd40b1f887fe97fff923e95df3b /libavcodec/libxvid.c | |
parent | 5182a2a235c3840e0ea0b5f3e352dc28646a11ed (diff) | |
download | ffmpeg-streaming-efe34e87ebf5119bbfabe353f9eb3a99c4c6d266.zip ffmpeg-streaming-efe34e87ebf5119bbfabe353f9eb3a99c4c6d266.tar.gz |
lavc/libxvid: fix mem leak in case of init failure
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Diffstat (limited to 'libavcodec/libxvid.c')
-rw-r--r-- | libavcodec/libxvid.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index aee9dac..020af32 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -359,7 +359,7 @@ static void xvid_correct_framerate(AVCodecContext *avctx) static av_cold int xvid_encode_init(AVCodecContext *avctx) { - int xerr, i; + int xerr, i, ret = -1; int xvid_flags = avctx->flags; struct xvid_context *x = avctx->priv_data; uint16_t *intra, *inter; @@ -659,13 +659,15 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) x->encoder_handle = xvid_enc_create.handle; avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); + if (!avctx->coded_frame) { + ret = AVERROR(ENOMEM); + goto fail; + } return 0; fail: xvid_encode_close(avctx); - return -1; + return ret; } static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, @@ -812,6 +814,7 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) av_freep(&x->twopassfile); av_freep(&x->intra_matrix); av_freep(&x->inter_matrix); + av_frame_free(&avctx->coded_frame); return 0; } |