mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
zlib: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36722 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
This commit is contained in:
1 parent
cf9556d8f7
commit
459fe6864e
1 file changed
+4
-3
+4
-3
@@ -23,6 +23,7 @@
|
||||
|
||||
const {
|
||||
ArrayBuffer,
|
||||
ArrayPrototypeForEach,
|
||||
ArrayPrototypeMap,
|
||||
ArrayPrototypePush,
|
||||
Error,
|
||||
@@ -798,8 +799,8 @@ function Brotli(opts, mode) {
|
||||
assert(mode === BROTLI_DECODE || mode === BROTLI_ENCODE);
|
||||
|
||||
TypedArrayPrototypeFill(brotliInitParamsArray, -1);
|
||||
if (opts && opts.params) {
|
||||
for (const origKey of ObjectKeys(opts.params)) {
|
||||
if (opts?.params) {
|
||||
ArrayPrototypeForEach(ObjectKeys(opts.params), (origKey) => {
|
||||
const key = +origKey;
|
||||
if (NumberIsNaN(key) || key < 0 || key > kMaxBrotliParam ||
|
||||
(brotliInitParamsArray[key] | 0) !== -1) {
|
||||
@@ -812,7 +813,7 @@ function Brotli(opts, mode) {
|
||||
'number', opts.params[origKey]);
|
||||
}
|
||||
brotliInitParamsArray[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const handle = mode === BROTLI_DECODE ?
|
||||
|
||||
Reference in new issue
Block a user