Fix memleak if vd_ffmpeg init fails

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21514 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2006-12-06 10:41:34 +00:00
parent e70b5d8500
commit 10021f03bc
1 changed files with 3 additions and 1 deletions

View File

@ -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);