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);