Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 822ac48

Browse filesBrowse files
aduh95danielleadams
authored andcommitted
buffer: make FastBuffer safe to construct
Using an explicit constructor is necessary to avoid relying on `Array.prototype[Symbol.iterator]` and `%ArrayIteratorPrototype%.next`, which can be mutated by users. PR-URL: #36587 Refs: #36428 Refs: #36532 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 8ac2016 commit 822ac48
Copy full SHA for 822ac48

File tree

Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/buffer.js‎

Copy file name to clipboardExpand all lines: lib/internal/buffer.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,14 @@ function writeFloatBackwards(val, offset = 0) {
949949
return offset;
950950
}
951951

952-
class FastBuffer extends Uint8Array {}
952+
class FastBuffer extends Uint8Array {
953+
// Using an explicit constructor here is necessary to avoid relying on
954+
// `Array.prototype[Symbol.iterator]`, which can be mutated by users.
955+
// eslint-disable-next-line no-useless-constructor
956+
constructor(bufferOrLength, byteOffset, length) {
957+
super(bufferOrLength, byteOffset, length);
958+
}
959+
}
953960

954961
function addBufferPrototypeMethods(proto) {
955962
proto.readBigUInt64LE = readBigUInt64LE;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.