Skip to content

Commit

Permalink
[Merge-110] [Stats] Handle the case of missing certificates.
Browse files Browse the repository at this point in the history
Certificates being missing is a sign of a bug (e.g. webrtc:14844, to be
fixed separately) which is why we have a DCHECK. But this DCHECK does
not protect against accessing the invalid iterator if it is a release
build. This CL makes that safe.

# Mobile bots not running properly
NOTRY=True

(cherry picked from commit 124d7c3)

Bug: chromium:1408392
Change-Id: I97a82786028e41c58ef8ef15002c3f959bbec7f1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291109
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Original-Commit-Position: refs/heads/main@{#39159}
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291380
Cr-Commit-Position: refs/branch-heads/5481@{#2}
Cr-Branched-From: 2e1a9a4-refs/heads/main@{#38901}
  • Loading branch information
henbos authored and WebRTC LUCI CQ committed Jan 24, 2023
1 parent dc7333f commit e0efbd4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pc/rtc_stats_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2192,16 +2192,17 @@ void RTCStatsCollector::ProduceTransportStats_n(
// exist.
const auto& certificate_stats_it =
transport_cert_stats.find(transport_name);
std::string local_certificate_id, remote_certificate_id;
RTC_DCHECK(certificate_stats_it != transport_cert_stats.cend());
std::string local_certificate_id;
if (certificate_stats_it->second.local) {
local_certificate_id = RTCCertificateIDFromFingerprint(
certificate_stats_it->second.local->fingerprint);
}
std::string remote_certificate_id;
if (certificate_stats_it->second.remote) {
remote_certificate_id = RTCCertificateIDFromFingerprint(
certificate_stats_it->second.remote->fingerprint);
if (certificate_stats_it != transport_cert_stats.cend()) {
if (certificate_stats_it->second.local) {
local_certificate_id = RTCCertificateIDFromFingerprint(
certificate_stats_it->second.local->fingerprint);
}
if (certificate_stats_it->second.remote) {
remote_certificate_id = RTCCertificateIDFromFingerprint(
certificate_stats_it->second.remote->fingerprint);
}
}

// There is one transport stats for each channel.
Expand Down

0 comments on commit e0efbd4

Please sign in to comment.