Skip to content
Permalink
Browse files Browse the repository at this point in the history
Added stack overflow check for hermes::vm:: hermesBuiltinApply
Summary: This adds a missing check for stack overflow.

Reviewed By: tmikov

Differential Revision: D20104955

fbshipit-source-id: 1f37e23d2e28ebcd3aa4176d134b8418e7059ebd
  • Loading branch information
kodafb authored and facebook-github-bot committed Feb 27, 2020
1 parent 82f0f97 commit 86543ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/VM/JSLib/HermesBuiltin.cpp
Expand Up @@ -653,6 +653,9 @@ hermesBuiltinApply(void *, Runtime *runtime, NativeArgs args) {

ScopedNativeCallFrame newFrame{
runtime, len, *fn, isConstructor, thisVal.getHermesValue()};
if (LLVM_UNLIKELY(newFrame.overflowed()))
return runtime->raiseStackOverflow(Runtime::StackOverflowKind::NativeStack);

for (uint32_t i = 0; i < len; ++i) {
newFrame->getArgRef(i) = argArray->at(runtime, i);
}
Expand Down
11 changes: 11 additions & 0 deletions test/hermes/stack-overflow-apply.js
Expand Up @@ -32,3 +32,14 @@ try {
print("caught:", e.name, e.message);
}
//CHECK: caught: RangeError {{.*}}

try {
v0 = [1.1];
function v1() {
v1(...v0);
}
v1();
} catch (e) {
print("caught:", e.name, e.message);
}
//CHECK: caught: RangeError {{.*}}

0 comments on commit 86543ac

Please sign in to comment.