From 6f3f69b459b6a33fe305c1d433478d535fc30c51 Mon Sep 17 00:00:00 2001 From: Johnny Date: Thu, 19 Aug 2021 19:14:58 +0800 Subject: [PATCH] fix stun packet memory leak. --- webrtc/WebRtcTransport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index cbbb3b72..845231e2 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -238,12 +238,12 @@ bool is_rtcp(char *buf) { void WebRtcTransport::inputSockData(char *buf, int len, RTC::TransportTuple *tuple) { if (RTC::StunPacket::IsStun((const uint8_t *) buf, len)) { - RTC::StunPacket *packet = RTC::StunPacket::Parse((const uint8_t *) buf, len); - if (packet == nullptr) { + std::unique_ptr packet(RTC::StunPacket::Parse((const uint8_t *) buf, len)); + if (!packet) { WarnL << "parse stun error" << std::endl; return; } - _ice_server->ProcessStunPacket(packet, tuple); + _ice_server->ProcessStunPacket(packet.get(), tuple); return; } if (is_dtls(buf)) {