Fixed crash when PCF is destroyed before DataChannel in ObjC
Bug: webrtc:9231
Change-Id: Ifad698b366be61d33ffca81cf4f8ca8aba2988a2
Reviewed-on: https://webrtc-review.googlesource.com/86040
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23771}
diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection.mm
index 8d10c34..b5c8cba 100644
--- a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection.mm
+++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection.mm
@@ -163,9 +163,9 @@
void PeerConnectionDelegateAdapter::OnDataChannel(
rtc::scoped_refptr<DataChannelInterface> data_channel) {
- RTCDataChannel *dataChannel =
- [[RTCDataChannel alloc] initWithNativeDataChannel:data_channel];
RTCPeerConnection *peer_connection = peer_connection_;
+ RTCDataChannel *dataChannel = [[RTCDataChannel alloc] initWithFactory:peer_connection.factory
+ nativeDataChannel:data_channel];
[peer_connection.delegate peerConnection:peer_connection
didOpenDataChannel:dataChannel];
}