зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358224 - pt 3 - fix leak in RTPHeaderExtension's rid char buffer. r=drno
Turns out since Firefox doesn't receive simulcast streams, we never noticed this leak. Convert RTPHeaderExtension.rid from a char* to rtc::scoped_ptr<char[]> so it gets deleted properly. This also requires a new copy constructor and assignment operator. MozReview-Commit-ID: Jh4Gp4dAl9g --HG-- extra : rebase_source : 8c1081fecd6e56a8f932af54fbd294adb85866f5
This commit is contained in:
Родитель
efa82b57bc
Коммит
4e635ff251
|
@ -33,7 +33,7 @@ bool MediaPipelineFilter::Filter(const webrtc::RTPHeader& header,
|
|||
|
||||
if (header.extension.hasRID &&
|
||||
remote_rid_set_.size() &&
|
||||
remote_rid_set_.count(header.extension.rid)) {
|
||||
remote_rid_set_.count(header.extension.rid.get())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,35 @@ RTPHeaderExtension::RTPHeaderExtension()
|
|||
hasVideoRotation(false),
|
||||
videoRotation(0),
|
||||
hasRID(false),
|
||||
rid(NULL) {
|
||||
rid(nullptr) {
|
||||
}
|
||||
|
||||
RTPHeaderExtension::RTPHeaderExtension(const RTPHeaderExtension& rhs) {
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
RTPHeaderExtension&
|
||||
RTPHeaderExtension::operator=(const RTPHeaderExtension& rhs) {
|
||||
hasTransmissionTimeOffset = rhs.hasTransmissionTimeOffset;
|
||||
transmissionTimeOffset = rhs.transmissionTimeOffset;
|
||||
hasAbsoluteSendTime = rhs.hasAbsoluteSendTime;
|
||||
absoluteSendTime = rhs.absoluteSendTime;
|
||||
hasTransportSequenceNumber = rhs.hasTransportSequenceNumber;
|
||||
transportSequenceNumber = rhs.transportSequenceNumber;
|
||||
|
||||
hasAudioLevel = rhs.hasAudioLevel;
|
||||
voiceActivity = rhs.voiceActivity;
|
||||
audioLevel = rhs.audioLevel;
|
||||
|
||||
hasVideoRotation = rhs.hasVideoRotation;
|
||||
videoRotation = rhs.videoRotation;
|
||||
|
||||
hasRID = rhs.hasRID;
|
||||
if (rhs.rid) {
|
||||
rid.reset(new char[strlen(rhs.rid.get())+1]);
|
||||
strcpy(rid.get(), rhs.rid.get());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RTPHeader::RTPHeader()
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -830,6 +831,8 @@ struct PacketTime {
|
|||
|
||||
struct RTPHeaderExtension {
|
||||
RTPHeaderExtension();
|
||||
RTPHeaderExtension(const RTPHeaderExtension& rhs);
|
||||
RTPHeaderExtension& operator=(const RTPHeaderExtension& rhs);
|
||||
|
||||
bool hasTransmissionTimeOffset;
|
||||
int32_t transmissionTimeOffset;
|
||||
|
@ -852,7 +855,7 @@ struct RTPHeaderExtension {
|
|||
|
||||
// RID values for simulcast; see draft-roach-avtext-rid
|
||||
bool hasRID;
|
||||
char *rid; // UTF8 string
|
||||
rtc::scoped_ptr<char[]> rid; // UTF8 string
|
||||
};
|
||||
|
||||
struct RTPHeader {
|
||||
|
|
|
@ -223,10 +223,10 @@ bool RtpReceiverImpl::IncomingRtpPacket(
|
|||
last_received_payload_length_ = payload_data_length;
|
||||
// RID rarely if ever changes
|
||||
if (rtp_header.extension.hasRID &&
|
||||
(!rid_ || strcmp(rtp_header.extension.rid, rid_) != 0)) {
|
||||
(!rid_ || strcmp(rtp_header.extension.rid.get(), rid_) != 0)) {
|
||||
delete [] rid_;
|
||||
rid_ = new char[strlen(rtp_header.extension.rid)+1];
|
||||
strcpy(rid_, rtp_header.extension.rid);
|
||||
rid_ = new char[strlen(rtp_header.extension.rid.get())+1];
|
||||
strcpy(rid_, rtp_header.extension.rid.get());
|
||||
}
|
||||
if (in_order) {
|
||||
if (last_received_timestamp_ != rtp_header.timestamp) {
|
||||
|
|
|
@ -444,12 +444,9 @@ void RtpHeaderParser::ParseOneByteExtensionHeader(
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO(jesup) - avoid allocating on each packet - high watermark the
|
||||
// RID buffer?
|
||||
char* ptrRID = new char[len + 2];
|
||||
memcpy(ptrRID, ptr, len + 1);
|
||||
ptrRID[len + 1] = '\0';
|
||||
header->extension.rid = ptrRID;
|
||||
header->extension.rid.reset(new char[len + 2]);
|
||||
memcpy(header->extension.rid.get(), ptr, len + 1);
|
||||
header->extension.rid.get()[len + 1] = '\0';
|
||||
header->extension.hasRID = true;
|
||||
break;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче