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
This commit is contained in:
Kevin Gozali 2019-02-04 14:52:53 -08:00 committed by Facebook Github Bot
parent aa39cb6d9f
commit 8ae185280d
1 changed files with 4 additions and 1 deletions

View File

@ -124,6 +124,7 @@ static Class getFallbackClassFromName(const char *name) {
// allow it to do so. // allow it to do so.
if ([module respondsToSelector:@selector(getTurboModuleWithJsInvoker:)]) { if ([module respondsToSelector:@selector(getTurboModuleWithJsInvoker:)]) {
auto turboModule = [module getTurboModuleWithJsInvoker:_jsInvoker]; auto turboModule = [module getTurboModuleWithJsInvoker:_jsInvoker];
assert(turboModule != nullptr);
_turboModuleCache.insert({moduleName, turboModule}); _turboModuleCache.insert({moduleName, turboModule});
return turboModule; return turboModule;
} }
@ -144,7 +145,9 @@ static Class getFallbackClassFromName(const char *name) {
* Step 2d: Return an exact sub-class of ObjC TurboModule * Step 2d: Return an exact sub-class of ObjC TurboModule
*/ */
auto turboModule = [_delegate getTurboModule:moduleName instance:module jsInvoker:_jsInvoker]; auto turboModule = [_delegate getTurboModule:moduleName instance:module jsInvoker:_jsInvoker];
_turboModuleCache.insert({moduleName, turboModule}); if (turboModule != nullptr) {
_turboModuleCache.insert({moduleName, turboModule});
}
return turboModule; return turboModule;
} }