Add a DCHECK for null port in FakePortAllocator.

If the socket server of the thread where FakePortAllocator lives is not
configured to be a VirtualSocketServer, there is a chance that we have a
null port in FakePortAllocator::StartGettingPort after creating the test
UDP port (for example, no permission to create a real socket if using a
PhysicalSocketServer), and subsequently this results in a crash when
connecting a signal in the port to a slot.

Bug: webrtc:9406
Change-Id: I1ba4526f7b9e104bed556f61d9348edc426fc1fc
Reviewed-on: https://webrtc-review.googlesource.com/83480
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@google.com>
Cr-Commit-Position: refs/heads/master@{#23606}
This commit is contained in:
Qingsi Wang 2018-06-13 16:08:14 -07:00 committed by Commit Bot
parent 60b6c1dfa9
commit 5d16d7fd52

View File

@ -129,6 +129,7 @@ class FakePortAllocatorSession : public PortAllocatorSession {
port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, 0, 0,
username(), password(), std::string(),
false));
RTC_DCHECK(port_);
port_->SignalDestroyed.connect(
this, &FakePortAllocatorSession::OnPortDestroyed);
AddPort(port_.get());