mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
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: https://github.com/nodejs/node/pull/36587 Refs: https://github.com/nodejs/node/pull/36428 Refs: https://github.com/nodejs/node/pull/36532 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
bd6f2303f4
commit
0187716be5
1 changed files with 8 additions and 1 deletions
|
@ -949,7 +949,14 @@ function writeFloatBackwards(val, offset = 0) {
|
|||
return offset;
|
||||
}
|
||||
|
||||
class FastBuffer extends Uint8Array {}
|
||||
class FastBuffer extends Uint8Array {
|
||||
// Using an explicit constructor here is necessary to avoid relying on
|
||||
// `Array.prototype[Symbol.iterator]`, which can be mutated by users.
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(bufferOrLength, byteOffset, length) {
|
||||
super(bufferOrLength, byteOffset, length);
|
||||
}
|
||||
}
|
||||
|
||||
function addBufferPrototypeMethods(proto) {
|
||||
proto.readBigUInt64LE = readBigUInt64LE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue