From 02687f40823ad776bace0ab64702283841515fa0 Mon Sep 17 00:00:00 2001 From: Michael Froman Date: Fri, 14 Jul 2023 16:03:17 -0500 Subject: [PATCH] Bug 1843113 - Vendor libwebrtc from a624ee1be7 Upstream commit: https://webrtc.googlesource.com/src/+/a624ee1be7a11e795a849edb2a27dc1137d2b63d [M114] Avoid touching channel after OnSctpDataChannelClosed (cherry picked from commit eec1810760ccbdf95c68ed0d2c2ae10a8575551a) Bug: chromium:1454086 Change-Id: I39573b706c4031d091c45a182b13cb3b2dba6233 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309920 Reviewed-by: Harald Alvestrand Commit-Queue: Tomas Gunnarsson Cr-Original-Commit-Position: refs/heads/main@{#40332} Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/310922 Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/branch-heads/5735@{#5} Cr-Branched-From: df7df199abd619e75b9f1d9a7e12fc3f3f748775-refs/heads/main@{#39949} --- third_party/libwebrtc/README.moz-ff-commit | 3 +++ third_party/libwebrtc/README.mozilla | 2 ++ third_party/libwebrtc/pc/data_channel_controller.cc | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/third_party/libwebrtc/README.moz-ff-commit b/third_party/libwebrtc/README.moz-ff-commit index c2fe797777bbc..b42cea31e8c99 100644 --- a/third_party/libwebrtc/README.moz-ff-commit +++ b/third_party/libwebrtc/README.moz-ff-commit @@ -23502,3 +23502,6 @@ e46e37b6f8 # MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh # base of lastest vendoring d20849d071 +# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a624ee1be7 diff --git a/third_party/libwebrtc/README.mozilla b/third_party/libwebrtc/README.mozilla index 9c9cb61b637a1..43f3d2e3c5cfe 100644 --- a/third_party/libwebrtc/README.mozilla +++ b/third_party/libwebrtc/README.mozilla @@ -15690,3 +15690,5 @@ libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-07-14T21:01:04.634768. # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-07-14T21:02:05.862286. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-07-14T21:03:04.820705. diff --git a/third_party/libwebrtc/pc/data_channel_controller.cc b/third_party/libwebrtc/pc/data_channel_controller.cc index 166e181cfe409..1746170f64b43 100644 --- a/third_party/libwebrtc/pc/data_channel_controller.cc +++ b/third_party/libwebrtc/pc/data_channel_controller.cc @@ -77,12 +77,16 @@ 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] { + SafeTask(signaling_safety_.flag(), [this, channel_id, state = state] { pc_->OnSctpDataChannelStateChanged(channel_id, state); })); }