From c6b1e6880b39160b1a37ab0b4fc0c3ca29ff7367 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 6 Nov 2009 15:45:55 +0000 Subject: [PATCH] Only call avcodec_close if the open succeeded before, otherwise avcodec_close will crash (happens e.g. when encoding ends before any frames were actually encoded, e.g. when an MPEG file was cut down to much so it no longer contains a full video frame). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29835 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/ve_lavc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libmpcodecs/ve_lavc.c b/libmpcodecs/ve_lavc.c index 66b6d100e4..e2ad55d0e0 100644 --- a/libmpcodecs/ve_lavc.c +++ b/libmpcodecs/ve_lavc.c @@ -911,7 +911,8 @@ static void uninit(struct vf_instance_s* vf){ av_freep(&lavc_venc_context->intra_matrix); av_freep(&lavc_venc_context->inter_matrix); - avcodec_close(lavc_venc_context); + if (lavc_venc_context->codec) + avcodec_close(lavc_venc_context); if(stats_file) fclose(stats_file);