JsepTransportController: Remove raw pointers to description objects
Remove member variables that point to objects owned externally (in practice by SdpOfferAnswerHandler). The objects also live on the
signaling thread whereas JsepTransportController performs
operations on the network thread. Removing the raw pointers avoids
the risk of referencing the description objects after they've been
deleted or if the state is inconsistent across threads.
Bug: webrtc:1515832
Change-Id: I852b2a3993964be817f93c46b5bc4b03121cde86
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334061
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41505}
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index d49506a..892a1d7 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -1996,8 +1996,11 @@
const cricket::SessionDescription* session_desc =
remote_description()->description();
+ const auto* local = local_description();
+
// NOTE: This will perform a BlockingCall() to the network thread.
- return transport_controller_s()->SetRemoteDescription(sdp_type, session_desc);
+ return transport_controller_s()->SetRemoteDescription(
+ sdp_type, local ? local->description() : nullptr, session_desc);
}
void SdpOfferAnswerHandler::ApplyRemoteDescription(
@@ -4910,13 +4913,15 @@
if (source == cricket::CS_LOCAL) {
const SessionDescriptionInterface* sdesc = local_description();
RTC_DCHECK(sdesc);
- return transport_controller_s()->SetLocalDescription(type,
- sdesc->description());
+ const auto* remote = remote_description();
+ return transport_controller_s()->SetLocalDescription(
+ type, sdesc->description(), remote ? remote->description() : nullptr);
} else {
const SessionDescriptionInterface* sdesc = remote_description();
RTC_DCHECK(sdesc);
- return transport_controller_s()->SetRemoteDescription(type,
- sdesc->description());
+ const auto* local = local_description();
+ return transport_controller_s()->SetRemoteDescription(
+ type, local ? local->description() : nullptr, sdesc->description());
}
}