]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11962: [core] Fix memory leak in switch_core_session_write_video_frame
authorMike Jerris <mike@signalwire.com>
Thu, 25 Jul 2019 20:41:29 +0000 (14:41 -0600)
committerMike Jerris <mike@signalwire.com>
Thu, 25 Jul 2019 20:41:39 +0000 (14:41 -0600)
src/switch_core_media.c

index 2b09bb8bb3b824d774eddd7413672be37f19a46d..5ef47fcaa3945bf42d2caa0a28e1df31d4bd2d65 100644 (file)
@@ -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;
 }