WebRtcVideoChannelBaseTest.InvalidRecvBufferSize: fix UAF.

The test could cause a UAF as the test exits while the lambda is
still running. Only seems to happen on Linux for some reason.

Bug: webrtc:12854
Change-Id: Ie0c0de09b675ef93dc195a6470752a772083029e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238425
Auto-Submit: Markus Handell <handellm@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35389}
This commit is contained in:
Markus Handell 2021-11-19 12:20:24 +01:00 committed by WebRTC LUCI CQ
parent 4be518d1fb
commit 68f06af6f6

View File

@ -1850,10 +1850,11 @@ TEST_F(WebRtcVideoChannelBaseTest, InvalidRecvBufferSize) {
// This particular hack, pauses the transport controller TQ while we
// change the field trial.
rtc::TaskQueue* tq = call_->GetTransportControllerSend()->GetWorkerQueue();
rtc::Event waiting, resume;
tq->PostTask([&waiting, &resume]() {
rtc::Event waiting, resume, conclude;
tq->PostTask([&waiting, &resume, &conclude]() {
waiting.Set();
resume.Wait(rtc::Event::kForever);
conclude.Set();
});
waiting.Wait(rtc::Event::kForever);
@ -1862,6 +1863,8 @@ TEST_F(WebRtcVideoChannelBaseTest, InvalidRecvBufferSize) {
SetUp();
resume.Set();
// Ensure we don't cause a UAF as the test scope exits.
conclude.Wait(rtc::Event::kForever);
// OK, now the test can carry on.