mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix undefined behavior in MethodInvoker (#46188)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46188 UBSAN identified undefined behavior when argCount == 0 (defining a variable array of zero length). Plus variable arrays in C++ are a clang extension. [ChangeLog]: [General] [Fixed] - Undefined behavior fix in MethodInvoker Reviewed By: nlutsenko Differential Revision: D61725776 fbshipit-source-id: 3729080eae8e78b65a558305f68782ae99edbc0a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8d3c4fb475
commit
09e88448ce
@@ -229,7 +229,9 @@ MethodCallResult MethodInvoker::invoke(
|
||||
auto env = Environment::current();
|
||||
auto argCount = signature_.size() - 2;
|
||||
JniLocalScope scope(env, static_cast<int>(argCount));
|
||||
jvalue args[argCount];
|
||||
std::vector<jvalue> argsStorage(
|
||||
argCount + 1); // ensure we have at least 1 element
|
||||
jvalue* args = argsStorage.data();
|
||||
std::transform(
|
||||
signature_.begin() + 2,
|
||||
signature_.end(),
|
||||
|
||||
Reference in New Issue
Block a user