From b1df04cb09205fbd7a87c09a62a95451e101d18d Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 19 Apr 2020 09:32:09 +0800 Subject: [PATCH] Fix double free bug for RTP --- trunk/src/app/srs_app_rtc_conn.cpp | 1 + trunk/src/kernel/srs_kernel_rtp.cpp | 8 -------- trunk/src/kernel/srs_kernel_rtp.hpp | 6 ++---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 5b79be9ca..401ecc01f 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -478,6 +478,7 @@ SrsRtcPackets::SrsRtcPackets(int nn_cache_max) cursor = 0; nn_cache = nn_cache_max; + // TODO: FIXME: We should allocate a smaller cache, and increase it when exhausted. cache = new SrsRtpPacket2[nn_cache]; } diff --git a/trunk/src/kernel/srs_kernel_rtp.cpp b/trunk/src/kernel/srs_kernel_rtp.cpp index fa98c5957..0215cb1a6 100644 --- a/trunk/src/kernel/srs_kernel_rtp.cpp +++ b/trunk/src/kernel/srs_kernel_rtp.cpp @@ -297,13 +297,6 @@ SrsRtpRawNALUs::~SrsRtpRawNALUs() srs_freep(p); } } - if (true) { - int nn_nalus = (int)extra_nalus.size(); - for (int i = 0; i < nn_nalus; i++) { - SrsSample* p = extra_nalus[i]; - srs_freep(p); - } - } } void SrsRtpRawNALUs::push_back(SrsSample* sample) @@ -356,7 +349,6 @@ srs_error_t SrsRtpRawNALUs::read_samples(vector& samples, int packet srs_assert(nn > 0); SrsSample* sample = new SrsSample(); - extra_nalus.push_back(sample); samples.push_back(sample); sample->bytes = p->bytes + pos; diff --git a/trunk/src/kernel/srs_kernel_rtp.hpp b/trunk/src/kernel/srs_kernel_rtp.hpp index 53601d126..eb811ee29 100644 --- a/trunk/src/kernel/srs_kernel_rtp.hpp +++ b/trunk/src/kernel/srs_kernel_rtp.hpp @@ -135,8 +135,6 @@ public: class SrsRtpRawNALUs : public ISrsEncoder { private: - // The returned samples. - std::vector extra_nalus; // We will manage the samples, but the sample itself point to the shared memory. std::vector nalus; int nn_bytes; @@ -162,7 +160,7 @@ class SrsRtpSTAPPayload : public ISrsEncoder public: // The NRI in NALU type. SrsAvcNaluType nri; - // The NALU samples. + // The NALU samples, we will manage the samples. // @remark We only refer to the memory, user must free its bytes. std::vector nalus; public: @@ -185,7 +183,7 @@ public: bool start; bool end; SrsAvcNaluType nalu_type; - // The NALU samples. + // The NALU samples, we manage the samples. // @remark We only refer to the memory, user must free its bytes. std::vector nalus; public: