From d8171750cdaab29068bc2affd5864b68cc4c0499 Mon Sep 17 00:00:00 2001 From: Isaac Date: Fri, 6 Apr 2018 23:02:15 +0200 Subject: [PATCH] only call avformat_close_input if mformatContext still has a value. On falure it should have been freed and NULL'd --- src/zm_ffmpeg_camera.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 0d5e70480..bd033fee6 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -362,9 +362,11 @@ int FfmpegCamera::OpenFfmpeg() { #if !LIBAVFORMAT_VERSION_CHECK(53, 17, 0, 25, 0) av_close_input_file( mFormatContext ); #else - avformat_close_input( &mFormatContext ); + if ( mFormatContext ) { + avformat_close_input( &mFormatContext ); + mFormatContext = NULL; + } #endif - mFormatContext = NULL; av_dict_free(&opts); return -1;