Skip to content

Commit

Permalink
TM iOS: guard against nullptr in module lookup
Browse files Browse the repository at this point in the history
Summary: Just tightened up the lookup logic to guard against nullptr.

Reviewed By: RSNara

Differential Revision: D13948001

fbshipit-source-id: 55bf46619712e60e195ea12f2b8eb799f80a3bbe
  • Loading branch information
fkgozali authored and facebook-github-bot committed Feb 4, 2019
1 parent b16260e commit 21b8542
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ - (instancetype)initWithRuntime:(jsi::Runtime *)runtime
// allow it to do so.
if ([module respondsToSelector:@selector(getTurboModuleWithJsInvoker:)]) {
auto turboModule = [module getTurboModuleWithJsInvoker:_jsInvoker];
assert(turboModule != nullptr);
_turboModuleCache.insert({moduleName, turboModule});
return turboModule;
}
Expand All @@ -144,7 +145,9 @@ - (instancetype)initWithRuntime:(jsi::Runtime *)runtime
* Step 2d: Return an exact sub-class of ObjC TurboModule
*/
auto turboModule = [_delegate getTurboModule:moduleName instance:module jsInvoker:_jsInvoker];
_turboModuleCache.insert({moduleName, turboModule});
if (turboModule != nullptr) {
_turboModuleCache.insert({moduleName, turboModule});
}
return turboModule;
}

Expand Down

0 comments on commit 21b8542

Please sign in to comment.