Guard .asObject calls with .isObject check in JSIExecutor

Summary:
When we call JSIExecutor::nativeCallSyncHook, we assume that the third argument is an object and call Value::asObject on it, before checking if the Object is an Array. Calling Value::asObject throws an error if the Value isn't an Object.

This diff includes an isObject check on the third argument.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D26735262

fbshipit-source-id: 96eb43d6c8bc1d78f3b5e0dc24ed6d419a446ecf
This commit is contained in:
Ramanpreet Nara
2021-03-01 20:48:10 -08:00
committed by Facebook GitHub Bot
parent 5772c4947d
commit 3e1d7da9c1
@@ -439,7 +439,7 @@ Value JSIExecutor::nativeCallSyncHook(const Value *args, size_t count) {
throw std::invalid_argument("nativeCallSyncHook arg count must be 3");
}
if (!args[2].asObject(*runtime_).isArray(*runtime_)) {
if (!args[2].isObject() || !args[2].asObject(*runtime_).isArray(*runtime_)) {
throw std::invalid_argument(
folly::to<std::string>("method parameters should be array"));
}