Merge pull request #1053 from johzzy/master

fix stun packet memory leak.
This commit is contained in:
夏楚 2021-08-20 16:03:41 +08:00 committed by GitHub
commit ce41fa268e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,12 +238,12 @@ bool is_rtcp(char *buf) {
void WebRtcTransport::inputSockData(char *buf, int len, RTC::TransportTuple *tuple) { void WebRtcTransport::inputSockData(char *buf, int len, RTC::TransportTuple *tuple) {
if (RTC::StunPacket::IsStun((const uint8_t *) buf, len)) { if (RTC::StunPacket::IsStun((const uint8_t *) buf, len)) {
RTC::StunPacket *packet = RTC::StunPacket::Parse((const uint8_t *) buf, len); std::unique_ptr<RTC::StunPacket> packet(RTC::StunPacket::Parse((const uint8_t *) buf, len));
if (packet == nullptr) { if (!packet) {
WarnL << "parse stun error" << std::endl; WarnL << "parse stun error" << std::endl;
return; return;
} }
_ice_server->ProcessStunPacket(packet, tuple); _ice_server->ProcessStunPacket(packet.get(), tuple);
return; return;
} }
if (is_dtls(buf)) { if (is_dtls(buf)) {