changeset 21498:f2c58d4fb683

Fix memleak if vd_ffmpeg init fails
author reimar
date Wed, 06 Dec 2006 10:41:34 +0000
parents 4a4af5271542
children 2e6ebc42fa9a
files libmpcodecs/vd_ffmpeg.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Wed Dec 06 10:11:23 2006 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Wed Dec 06 10:41:34 2006 +0000
@@ -242,6 +242,7 @@
     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 @@
     /* 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 @@
             );
     }
 
-    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);