From 11251c3db0e271c3ca515a13a94cae5d2a7b5c1a Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Mon, 15 May 2023 15:05:16 -0700 Subject: [PATCH] create fallback contextContainer (#37441) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37441 Changelog: [Internal] i just noticed that `[_delegate createContextContainer]` can be null because it returns `shared_ptr`, we should protect against that! Reviewed By: javache Differential Revision: D45805196 fbshipit-source-id: 645815812da1718e1025c7e6b2763e698d86b59a --- .../react/bridgeless/platform/ios/Core/RCTInstance.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTInstance.mm b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTInstance.mm index 56535683c78..3873592bf54 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTInstance.mm @@ -237,6 +237,9 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags) RCTLogSetBridgelessCallableJSModules(_bridgeModuleDecorator.callableJSModules); auto contextContainer = [_delegate createContextContainer]; + if (!contextContainer) { + contextContainer = std::make_shared(); + } contextContainer->insert( "RCTImageLoader", facebook::react::wrapManagedObject([_turboModuleManager moduleForName:"RCTImageLoader"])); contextContainer->insert(