From 10021f03bc9d2b3b2346cbb3cf5b0dcc747c1d24 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 6 Dec 2006 10:41:34 +0000 Subject: [PATCH] Fix memleak if vd_ffmpeg init fails git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21514 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vd_ffmpeg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index 3f66d2e81e..f94bd31f18 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -242,6 +242,7 @@ static int init(sh_video_t *sh){ lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll); if(!lavc_codec){ mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh->codec->dll); + uninit(sh); return 0; } @@ -406,6 +407,7 @@ static int init(sh_video_t *sh){ /* open it */ if (avcodec_open(avctx, lavc_codec) < 0) { mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec); + uninit(sh); return 0; } mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); @@ -429,7 +431,7 @@ static void uninit(sh_video_t *sh){ ); } - if (avcodec_close(avctx) < 0) + if (avctx && avctx->codec && avcodec_close(avctx) < 0) mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); av_freep(&avctx->extradata);