From 9ef1db7833550b62956f03b6312de7852c797105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=AE=97=E5=AF=8C?= Date: Fri, 20 Sep 2024 12:44:42 +0800 Subject: [PATCH] =?UTF-8?q?cherry=20pick=20d8ccd4b=20from=20https://gitee.?= =?UTF-8?q?com/ma-zongfu/chromium=5Fthird=5Fparty=5Fwebrtc/pulls/49=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DCVE-2023-3727?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 马宗富 --- pc/data_channel_controller.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc index 166e181c..b7949e75 100644 --- a/pc/data_channel_controller.cc +++ b/pc/data_channel_controller.cc @@ -77,14 +77,18 @@ void DataChannelController::OnChannelStateChanged( SctpDataChannel* channel, DataChannelInterface::DataState state) { RTC_DCHECK_RUN_ON(network_thread()); + + // Stash away the internal id here in case `OnSctpDataChannelClosed` ends up + // releasing the last reference to the channel. + const int channel_id = channel->internal_id(); + if (state == DataChannelInterface::DataState::kClosed) OnSctpDataChannelClosed(channel); signaling_thread()->PostTask( - SafeTask(signaling_safety_.flag(), - [this, channel_id = channel->internal_id(), state = state] { - pc_->OnSctpDataChannelStateChanged(channel_id, state); - })); + SafeTask(signaling_safety_.flag(), [this, channel_id, state] { + pc_->OnSctpDataChannelStateChanged(channel_id, state); + })); } void DataChannelController::OnDataReceived( -- Gitee