aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/napi.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-15 02:51:44 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-15 02:51:44 -0800
commitc7d16d2ed51afd12581ac4a60435ad202d01a8d9 (patch)
tree55d8cea584a1daef8c0529344cf8eba5f0e02b7e /src/bun.js/bindings/napi.cpp
parentd150a73b9bac935fc2f7fc1872e73221fbecdf13 (diff)
downloadbun-c7d16d2ed51afd12581ac4a60435ad202d01a8d9.tar.gz
bun-c7d16d2ed51afd12581ac4a60435ad202d01a8d9.tar.zst
bun-c7d16d2ed51afd12581ac4a60435ad202d01a8d9.zip
ensure we allocate for > 6 arguments
Diffstat (limited to 'src/bun.js/bindings/napi.cpp')
-rw-r--r--src/bun.js/bindings/napi.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp
index ecae69427..bebdd5134 100644
--- a/src/bun.js/bindings/napi.cpp
+++ b/src/bun.js/bindings/napi.cpp
@@ -1185,9 +1185,20 @@ static JSC_DEFINE_HOST_FUNCTION(NapiClass_ConstructorFunction,
RETURN_IF_EXCEPTION(scope, {});
+ size_t count = callFrame->argumentCount();
+ MarkedArgumentBuffer args;
+
+ if (count > 6) {
+ for (size_t i = 6; i < count; i++) {
+ args.append(callFrame->uncheckedArgument(i));
+ }
+ }
+
callFrame->setThisValue(prototype->subclass(newTarget));
napi->constructor()(globalObject, callFrame);
- size_t count = callFrame->argumentCount();
+ RETURN_IF_EXCEPTION(scope, {});
+
+ JSC::JSValue thisValue = callFrame->thisValue();
switch (count) {
case 0: {
@@ -1230,15 +1241,11 @@ static JSC_DEFINE_HOST_FUNCTION(NapiClass_ConstructorFunction,
JSC::ensureStillAliveHere(callFrame->argument(3));
JSC::ensureStillAliveHere(callFrame->argument(4));
JSC::ensureStillAliveHere(callFrame->argument(5));
- for (int i = 6; i < count; i++) {
- JSC::ensureStillAliveHere(callFrame->argument(i));
- }
break;
}
}
- RETURN_IF_EXCEPTION(scope, {});
- RELEASE_AND_RETURN(scope, JSValue::encode(callFrame->thisValue()));
+ RELEASE_AND_RETURN(scope, JSValue::encode(thisValue));
}
NapiClass* NapiClass::create(VM& vm, Zig::GlobalObject* globalObject, const char* utf8name,