From 51a0c653e4af6b6323ede33eac399f3ed9977914 Mon Sep 17 00:00:00 2001 From: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:03:13 +0100 Subject: [PATCH] Add null checks in ShellSectionRenderer --- .../Handlers/Shell/iOS/ShellSectionRenderer.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs index d4e219bf0891..e877793b43f3 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs @@ -124,7 +124,7 @@ bool DidPopItem(UINavigationBar _, UINavigationItem __) // Bounds check: ensure we have a valid index for pages array int targetIndex = NavigationBar.Items.Length - 1; - if (targetIndex < 0 || targetIndex >= pages.Count) + if (targetIndex < 0 || targetIndex >= pages.Count || pages[targetIndex] is null) return true; _shellSection.SyncStackDownTo(pages[targetIndex]); @@ -577,10 +577,7 @@ Element ElementForViewController(UIViewController viewController) foreach (var child in ShellSection.Stack) { - if (child == null) - continue; - var renderer = (IPlatformViewHandler)child.Handler; - if (viewController == renderer.ViewController) + if (child?.Handler is IPlatformViewHandler { ViewController: var vc } && viewController == vc) return child; }