From 4322a136f1d23585e6b95c9d38e1f56de4cb81d0 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Thu, 18 Jul 2013 21:23:40 -0700 Subject: [PATCH] xrdpvr: fix a crash in xrdpvr_deinit_player --- xrdpvr/xrdpvr.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/xrdpvr/xrdpvr.c b/xrdpvr/xrdpvr.c index 6f39e975..89daccf8 100644 --- a/xrdpvr/xrdpvr.c +++ b/xrdpvr/xrdpvr.c @@ -92,11 +92,27 @@ xrdpvr_deinit_player(void *channel, int stream_id) } /* do local clean up */ - av_free(g_psi.frame); - avcodec_close(g_psi.p_audio_codec_ctx); - avcodec_close(g_psi.p_video_codec_ctx); + if (g_psi.frame != 0) + { + av_free(g_psi.frame); + g_psi.frame = 0; + } + if (g_psi.p_audio_codec_ctx != 0) + { + avcodec_close(g_psi.p_audio_codec_ctx); + g_psi.p_audio_codec_ctx = 0; + } + if (g_psi.p_video_codec_ctx != 0) + { + avcodec_close(g_psi.p_video_codec_ctx); + g_psi.p_video_codec_ctx = 0; + } //avformat_close_input(&g_psi.p_format_ctx); - av_close_input_file(g_psi.p_format_ctx); + if (g_psi.p_format_ctx != 0) + { + av_close_input_file(g_psi.p_format_ctx); + g_psi.p_format_ctx = 0; + } /* do remote cleanup */