From 89f7094513d2d0228d2f19fb1436f356466b4e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 6 Aug 2026 19:46:29 +0200 Subject: [PATCH] iOS: Fix use-after-free when Vulkan init fails viewDidLoad deleted the graphics context on InitAPI failure but left the member pointing at the freed object, and then kept going - runVulkanRenderLoop and shutdown would both use it. Null it out instead; both already check. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01JZk5y4Fzw811WJoNWZb8Sc --- ios/ViewControllerMetal.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ios/ViewControllerMetal.mm b/ios/ViewControllerMetal.mm index 62645f52d2..671916907d 100644 --- a/ios/ViewControllerMetal.mm +++ b/ios/ViewControllerMetal.mm @@ -206,7 +206,9 @@ static void VulkanRenderLoop(GraphicsContext *graphicsContext, CAMetalLayer *met g_Config.iGPUBackend = (int)GPUBackend::OPENGL; SetGPUBackend(GPUBackend::OPENGL); delete graphicsContext; - // TODO: What to do here? + graphicsContext = nullptr; // The render loop and shutdown check for this. + // TODO: What to do here? We've switched the config over to GL, but we're still the Metal view controller, + // so we won't render anything until the app gets restarted. } [self updateResolutionWithView:self.view];