From 9c85465a583397d9b264854efa974fc1a381bf79 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Thu, 20 Jul 2023 19:16:56 -0700 Subject: fix process.exit status code handling (#3714) --- src/bun.js/bindings/Process.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 872ec41c3..78f473ec2 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -379,14 +379,9 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionExit, return JSC::JSValue::encode(JSC::JSValue {}); } - int extiCode32 = arg0.toInt32(globalObject); + int extiCode32 = arg0.toInt32(globalObject) % 256; RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); - if (extiCode32 < 0 || extiCode32 > 127) { - throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); - return JSC::JSValue::encode(JSC::JSValue {}); - } - exitCode = static_cast(extiCode32); } else if (!arg0.isUndefinedOrNull()) { throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); @@ -1142,14 +1137,9 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObj return JSC::JSValue::encode(JSC::JSValue {}); } - int extiCode32 = arg0.toInt32(globalObject); + int extiCode32 = arg0.toInt32(globalObject) % 256; RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); - if (extiCode32 < 0 || extiCode32 > 127) { - throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); - return JSC::JSValue::encode(JSC::JSValue {}); - } - exitCode = static_cast(extiCode32); } else if (!arg0.isUndefinedOrNull()) { throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); -- cgit v1.2.3