Skip to content

Commit 8ae1852

Browse files
fkgozalifacebook-github-bot
authored andcommitted
TM iOS: guard against nullptr in module lookup
Summary: Just tightened up the lookup logic to guard against nullptr. Reviewed By: RSNara Differential Revision: D13948001 fbshipit-source-id: 55bf46619712e60e195ea12f2b8eb799f80a3bbe
1 parent aa39cb6 commit 8ae1852

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ - (instancetype)initWithRuntime:(jsi::Runtime *)runtime
124124
// allow it to do so.
125125
if ([module respondsToSelector:@selector(getTurboModuleWithJsInvoker:)]) {
126126
auto turboModule = [module getTurboModuleWithJsInvoker:_jsInvoker];
127+
assert(turboModule != nullptr);
127128
_turboModuleCache.insert({moduleName, turboModule});
128129
return turboModule;
129130
}
@@ -144,7 +145,9 @@ - (instancetype)initWithRuntime:(jsi::Runtime *)runtime
144145
* Step 2d: Return an exact sub-class of ObjC TurboModule
145146
*/
146147
auto turboModule = [_delegate getTurboModule:moduleName instance:module jsInvoker:_jsInvoker];
147-
_turboModuleCache.insert({moduleName, turboModule});
148+
if (turboModule != nullptr) {
149+
_turboModuleCache.insert({moduleName, turboModule});
150+
}
148151
return turboModule;
149152
}
150153

0 commit comments

Comments
 (0)