[ObjC] Fix strong reference check in RTCNetworkMonitor.

Strong reference must be validated when created from weak reference,
otherwise crashes are possible and actually observed via Crashlytics.

Bug: None
Change-Id: I68355080ba3b20119c913a9c7e27edc07b5447cd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/375901
Commit-Queue: Yury Yarashevich <yura.yaroshevich@gmail.com>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43837}
This commit is contained in:
Yury Yarashevich 2025-01-30 16:57:45 +01:00 committed by WebRTC LUCI CQ
parent 6f17d09dd1
commit 1181edda58

View File

@ -67,10 +67,10 @@ rtc::AdapterType AdapterTypeFromInterfaceType(
RTCLog(@"NW path monitor created.");
__weak RTCNetworkMonitor *weakSelf = self;
nw_path_monitor_set_update_handler(_pathMonitor, ^(nw_path_t path) {
if (weakSelf == nil) {
RTCNetworkMonitor *strongSelf = weakSelf;
if (strongSelf == nil) {
return;
}
RTCNetworkMonitor *strongSelf = weakSelf;
RTCLog(@"NW path monitor: updated.");
nw_path_status_t status = nw_path_get_status(path);
if (status == nw_path_status_invalid) {