Skip to content

Commit 303f947

Browse files
youennfphiln
authored andcommitted
[WebRTC] heap-use-after-free : webrtc::`anonymous namespace'::ProduceRemoteInboundRtpStreamStatsFromReportBlockData
https://bugs.webkit.org/show_bug.cgi?id=253510 rdar://106063452 Reviewed by Eric Carlson. We first cherry-pick libwebrc b2be392c708c975ff5a81d8cd4dba588752a8dad to remove duplicate RTCCodec entries. We then apply da6297dc53cb2eaae7b1c5381652de9d707a7d48. * Source/ThirdParty/libwebrtc/Source/webrtc/api/stats/rtc_stats_report.h: * Source/ThirdParty/libwebrtc/Source/webrtc/pc/rtc_stats_collector.cc: * Source/ThirdParty/libwebrtc/Source/webrtc/pc/rtc_stats_collector_unittest.cc: * Source/ThirdParty/libwebrtc/Source/webrtc/pc/test/fake_peer_connection_for_stats.h: (webrtc::FakePeerConnectionForStats::AddVoiceChannel): (webrtc::FakePeerConnectionForStats::AddVideoChannel): (webrtc::FakePeerConnectionForStats::GetOrCreateFirstTransceiverOfType): (webrtc::FakePeerConnectionForStats::CreateTransceiverOfType): * Source/ThirdParty/libwebrtc/Source/webrtc/stats/rtc_stats_report.cc: Originally-landed-as: 259548.382@safari-7615-branch (adde9296b1b1). rdar://106063452 Canonical link: https://commits.webkit.org/264332@main
1 parent 573b7c2 commit 303f947

5 files changed

Lines changed: 417 additions & 82 deletions

File tree

Source/ThirdParty/libwebrtc/Source/webrtc/api/stats/rtc_stats_report.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <map>
1818
#include <memory>
1919
#include <string>
20+
#include <utility>
2021
#include <vector>
2122

2223
#include "api/ref_counted_base.h"
@@ -68,6 +69,18 @@ class RTC_EXPORT RTCStatsReport final
6869

6970
int64_t timestamp_us() const { return timestamp_us_; }
7071
void AddStats(std::unique_ptr<const RTCStats> stats);
72+
// On success, returns a non-owning pointer to `stats`. If the stats ID is not
73+
// unique, `stats` is not inserted and nullptr is returned.
74+
template <typename T>
75+
T* TryAddStats(std::unique_ptr<T> stats) {
76+
T* stats_ptr = stats.get();
77+
if (!stats_
78+
.insert(std::make_pair(std::string(stats->id()), std::move(stats)))
79+
.second) {
80+
return nullptr;
81+
}
82+
return stats_ptr;
83+
}
7184
const RTCStats* Get(const std::string& id) const;
7285
size_t size() const { return stats_.size(); }
7386

0 commit comments

Comments
 (0)