From 997a98cbd795e648da72947872be613422daf8f7 Mon Sep 17 00:00:00 2001 From: rainfly Date: Tue, 17 Apr 2018 16:07:43 +0800 Subject: [PATCH 1/3] Update srs_kernel_ts.cpp memory leak --- trunk/src/kernel/srs_kernel_ts.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index fad50ea2ba..415cf87a82 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -184,6 +184,8 @@ SrsTsMessage* SrsTsMessage::detach() cp->sid = sid; cp->PES_packet_length = PES_packet_length; cp->continuity_counter = continuity_counter; + //use the origin msg's payload, just free ours + srs_freep(cp->payload); cp->payload = payload; payload = NULL; return cp; From 2acaa57800f67e894f9233c2c8edeaca6dc6c105 Mon Sep 17 00:00:00 2001 From: rainfly Date: Tue, 17 Apr 2018 16:11:13 +0800 Subject: [PATCH 2/3] Update srs_main_ingest_hls.cpp memory leak --- trunk/src/main/srs_main_ingest_hls.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index 3321e29c85..31336661a4 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -902,7 +902,8 @@ int SrsIngestSrsOutput::parse_message_queue() nb_videos--; } queue.erase(it); - + //release detached ts msg + srs_freep(msg); // parse the stream. SrsStream avs; if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) { @@ -921,6 +922,7 @@ int SrsIngestSrsOutput::parse_message_queue() return ret; } } + } return ret; @@ -936,7 +938,8 @@ int SrsIngestSrsOutput::flush_message_queue() SrsTsMessage* msg = it->second; queue.erase(it); - + //release detached ts msg + srs_freep(msg); // parse the stream. SrsStream avs; if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) { From 08727cb7bdadd4c92aba0a22f9f70dc8a20e023a Mon Sep 17 00:00:00 2001 From: rainfly Date: Tue, 17 Apr 2018 16:16:15 +0800 Subject: [PATCH 3/3] Update srs_main_ingest_hls.cpp --- trunk/src/main/srs_main_ingest_hls.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index 31336661a4..09053d1277 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -902,27 +902,29 @@ int SrsIngestSrsOutput::parse_message_queue() nb_videos--; } queue.erase(it); - //release detached ts msg - srs_freep(msg); // parse the stream. SrsStream avs; if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) { srs_error("mpegts: initialize av stream failed. ret=%d", ret); + srs_freep(msg); return ret; } // publish audio or video. if (msg->channel->stream == SrsTsStreamVideoH264) { if ((ret = on_ts_video(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } if (msg->channel->stream == SrsTsStreamAudioAAC) { if ((ret = on_ts_audio(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } - + //release detached ts msg + srs_freep(msg); } return ret; @@ -938,26 +940,29 @@ int SrsIngestSrsOutput::flush_message_queue() SrsTsMessage* msg = it->second; queue.erase(it); - //release detached ts msg - srs_freep(msg); // parse the stream. SrsStream avs; if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) { srs_error("mpegts: initialize av stream failed. ret=%d", ret); + srs_freep(msg); return ret; } // publish audio or video. if (msg->channel->stream == SrsTsStreamVideoH264) { if ((ret = on_ts_video(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } if (msg->channel->stream == SrsTsStreamAudioAAC) { if ((ret = on_ts_audio(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } + //release detached ts msg + srs_freep(msg); } return ret;