From 99ea7c3eaa7a66fcf053985dbe5a4c6514344651 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Sun, 5 Nov 2023 07:51:31 +0000 Subject: [PATCH] Use pass-by-value in delayed scheduling of OnSentPacket The change in the test failed to trigger an error on msan, but making the change anyway out of an abundance of caution. Bug: chromium:1496240 Change-Id: Ifa1b632f4e9ddb413f0eb23aba3f5b321b287b06 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/326080 Commit-Queue: Harald Alvestrand Reviewed-by: Victor Boivie Cr-Commit-Position: refs/heads/main@{#41083} --- pc/rtp_transport.cc | 2 +- pc/rtp_transport_unittest.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pc/rtp_transport.cc b/pc/rtp_transport.cc index cddfaca4fc..42828a7ab1 100644 --- a/pc/rtp_transport.cc +++ b/pc/rtp_transport.cc @@ -228,7 +228,7 @@ void RtpTransport::OnSentPacket(rtc::PacketTransportInternal* packet_transport, packet_transport == rtcp_packet_transport_); if (processing_sent_packet_) { TaskQueueBase::Current()->PostTask(SafeTask( - safety_.flag(), [this, &sent_packet] { SendSentPacket(sent_packet); })); + safety_.flag(), [this, sent_packet] { SendSentPacket(sent_packet); })); return; } processing_sent_packet_ = true; diff --git a/pc/rtp_transport_unittest.cc b/pc/rtp_transport_unittest.cc index d3eb666c9f..6b8e616799 100644 --- a/pc/rtp_transport_unittest.cc +++ b/pc/rtp_transport_unittest.cc @@ -359,14 +359,15 @@ TEST(RtpTransportTest, RecursiveOnSentPacketDoesNotCrash) { TransportObserver observer(&transport); const rtc::PacketOptions options; const int flags = 0; - rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen); fake_rtp.SetWritable(true); observer.SetActionOnSentPacket([&]() { + rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen); if (observer.sent_packet_count() < 2) { transport.SendRtpPacket(&rtp_data, options, flags); } }); + rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen); transport.SendRtpPacket(&rtp_data, options, flags); EXPECT_EQ(observer.sent_packet_count(), 1); EXPECT_EQ_WAIT(observer.sent_packet_count(), 2, kShortTimeout);