From 0a3836a882078070451b1d17e1e08fcc45ff1dd0 Mon Sep 17 00:00:00 2001 From: Chuck Hays Date: Tue, 21 Dec 2021 14:24:46 -0600 Subject: [PATCH] Add missing respondsToSelector call for new optional delegate method. Without checking respondsToSelector, clients that don't implement the optional delegate method will crash. Bug: webrtc:13446 Change-Id: I3b06b15e818ca80e6afae9491c30f38c6b262eb2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242600 Reviewed-by: Henrik Andreassson Auto-Submit: Chuck Hays Commit-Queue: Chuck Hays Cr-Commit-Position: refs/heads/main@{#35573} --- sdk/objc/api/peerconnection/RTCPeerConnection.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index 24242acadd..71ca10051e 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -239,7 +239,10 @@ void PeerConnectionDelegateAdapter::OnIceCandidateError(const std::string &addre url:url errorCode:error_code errorText:error_text]; - [peer_connection.delegate peerConnection:peer_connection didFailToGatherIceCandidate:event]; + if ([peer_connection.delegate respondsToSelector:@selector(peerConnection: + didFailToGatherIceCandidate:)]) { + [peer_connection.delegate peerConnection:peer_connection didFailToGatherIceCandidate:event]; + } } void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(