aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-01 17:09:59 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-01 17:09:59 -0700
commita4fe433db776e9ffcc532c8aeb9ea93ff0a3c02a (patch)
treee9ff6ae7f41d1ce844e839ea57099fe7662b2897 /src
parentf3833376e75a2353285fc884f31a5be97a917b6e (diff)
downloadbun-a4fe433db776e9ffcc532c8aeb9ea93ff0a3c02a.tar.gz
bun-a4fe433db776e9ffcc532c8aeb9ea93ff0a3c02a.tar.zst
bun-a4fe433db776e9ffcc532c8aeb9ea93ff0a3c02a.zip
Slight fixup
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/JSBuffer.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp
index 10f9aab5a..87e1d4048 100644
--- a/src/bun.js/bindings/JSBuffer.cpp
+++ b/src/bun.js/bindings/JSBuffer.cpp
@@ -1476,13 +1476,19 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS
offset = static_cast<uint32_t>(istart);
length = (length > offset) ? (length - offset) : 0;
} else {
- int32_t ioffset = arg1.toInt32(lexicalGlobalObject);
- RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined()));
+
+ int32_t ioffset = 0;
+
+ if (!arg1.isUndefined()) {
+ ioffset = arg1.toInt32(lexicalGlobalObject);
+ RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined()));
+ }
if (ioffset < 0) {
throwTypeError(lexicalGlobalObject, scope, "Offset must be a positive integer"_s);
return JSC::JSValue::encode(jsUndefined());
}
+
offset = static_cast<uint32_t>(ioffset);
length = (length > offset) ? (length - offset) : 0;