aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Yifei Wang <buffaybu@gmail.com> 2023-08-05 07:08:25 +0800
committerGravatar GitHub <noreply@github.com> 2023-08-04 16:08:25 -0700
commitbdbc21ff7bc0bb1d2215a0a5bd892eaade41e76f (patch)
treeb00a58214e76c0fb62b644fc7663365c0c601e9f /src
parentff315a3bf2ae30b3e933fa267c96baefc1164399 (diff)
downloadbun-bdbc21ff7bc0bb1d2215a0a5bd892eaade41e76f.tar.gz
bun-bdbc21ff7bc0bb1d2215a0a5bd892eaade41e76f.tar.zst
bun-bdbc21ff7bc0bb1d2215a0a5bd892eaade41e76f.zip
Buffer.copy should ignore out-of-range sourceEnd (#3971)
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/JSBuffer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp
index e420e24ef..26047aa3d 100644
--- a/src/bun.js/bindings/JSBuffer.cpp
+++ b/src/bun.js/bindings/JSBuffer.cpp
@@ -949,7 +949,8 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_copyBody(JSC::JSGlob
}
targetStart = std::min(targetStart, targetEnd);
- sourceStart = std::min(sourceStart, std::min(sourceEnd, sourceEndInit));
+ sourceEnd = std::min(sourceEnd, sourceEndInit);
+ sourceStart = std::min(sourceStart, sourceEnd);
auto sourceLength = sourceEnd - sourceStart;
auto targetLength = targetEnd - targetStart;