From d16575d28842002f97c921c6fab858f41250385c Mon Sep 17 00:00:00 2001 From: Mike Jerris Date: Thu, 25 Jul 2019 14:41:29 -0600 Subject: [PATCH] FS-11962: [core] Fix memory leak in switch_core_session_write_video_frame --- src/switch_core_media.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 2b09bb8bb3..5ef47fcaa3 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -14545,6 +14545,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor switch_status_t encode_status; switch_frame_t write_frame = {0}; switch_rtp_engine_t *v_engine = NULL; + switch_bool_t need_free = SWITCH_FALSE; switch_assert(session); if (!(smh = session->media_handle)) { @@ -14679,6 +14680,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor bp->video_ping_frame = NULL; } + if (bug_frame.img && bug_frame.img != img) { + need_free = SWITCH_TRUE; + img = bug_frame.img; + } + if (switch_core_media_bug_test_flag(bp, SMBF_SPY_VIDEO_STREAM_BLEG) && !patched) { switch_core_media_bug_patch_spy_frame(bp, img, SWITCH_RW_WRITE); } @@ -14751,6 +14757,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor switch_img_free(&dup_img); + if (need_free) { + switch_img_free(&frame->img); + } + return status; }