Using nullopt when connection is nullptr.

During SelectConnectionToPing, optional connection had the value of nullptr which led the code to crash.

Bug: None
Change-Id: Ibe9a54b71bbd62f3b80d676ca80d64ff951dda51
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206081
Commit-Queue: Tim Na <natim@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33197}
This commit is contained in:
Tim Na 2021-02-05 10:23:53 -08:00 committed by Commit Bot
parent ccdf50ba09
commit 203b549ee2

View File

@ -87,7 +87,9 @@ class IceControllerInterface {
// This represents the result of a call to SelectConnectionToPing.
struct PingResult {
PingResult(const Connection* conn, int _recheck_delay_ms)
: connection(conn), recheck_delay_ms(_recheck_delay_ms) {}
: connection(conn ? absl::optional<const Connection*>(conn)
: absl::nullopt),
recheck_delay_ms(_recheck_delay_ms) {}
// Connection that we should (optionally) ping.
const absl::optional<const Connection*> connection;