summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorud2 <sjx233@qq.com>2024-06-28 05:45:46 +0800
committerGitHub <noreply@github.com>2024-06-27 21:45:46 +0000
commit8d14a9db2f0dd66492fadc498ae0070398d31d89 (patch)
treefb3f215845fc8e8bb30c96c9ac7e55878a1ee0b7
parent67dcd6db518446574d3a1e33f4ce536fcdc4fd25 (diff)
fix(ext/node): make next tick queue resilient to `Array.prototype` tampering (#24361)
Closes #24358.
-rw-r--r--ext/node/polyfills/internal/fixed_queue.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/node/polyfills/internal/fixed_queue.ts b/ext/node/polyfills/internal/fixed_queue.ts
index d98a5e507..0a2209c8d 100644
--- a/ext/node/polyfills/internal/fixed_queue.ts
+++ b/ext/node/polyfills/internal/fixed_queue.ts
@@ -1,8 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// Copyright Joyent, Inc. and other Node contributors.
-// TODO(petamoriken): enable prefer-primordials for node polyfills
-// deno-lint-ignore-file prefer-primordials
+import { primordials } from "ext:core/mod.js";
+const { ArrayFrom } = primordials;
// Currently optimal queue size, tested on V8 6.0 - 6.6. Must be power of two.
const kSize = 2048;
@@ -65,7 +65,7 @@ class FixedCircularBuffer {
constructor() {
this.bottom = 0;
this.top = 0;
- this.list = new Array(kSize);
+ this.list = ArrayFrom({ __proto__: null, length: kSize });
this.next = null;
}
@@ -111,11 +111,13 @@ export class FixedQueue {
// and sets it as the new main queue.
this.head = this.head.next = new FixedCircularBuffer();
}
+ // deno-lint-ignore prefer-primordials -- `push` is a method of `FixedCircularBuffer`
this.head.push(data);
}
shift() {
const tail = this.tail;
+ // deno-lint-ignore prefer-primordials -- `shift` is a method of `FixedCircularBuffer`
const next = tail.shift();
if (tail.isEmpty() && tail.next !== null) {
// If there is another queue, it forms the new tail.