From 3e1d7da9c1e33ef6e238adb071c9a536fc77bccf Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Mon, 1 Mar 2021 20:45:04 -0800 Subject: [PATCH] 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 --- ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index f4908914460..f1d4c517060 100644 --- a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -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("method parameters should be array")); }