Skip to content

Commit 459fe68

Browse files
aduh95targos
authored andcommitted
zlib: refactor to avoid unsafe array iteration
PR-URL: #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>
1 parent cf9556d commit 459fe68

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎lib/zlib.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const{
2525
ArrayBuffer,
26+
ArrayPrototypeForEach,
2627
ArrayPrototypeMap,
2728
ArrayPrototypePush,
2829
Error,
@@ -798,8 +799,8 @@ function Brotli(opts, mode) {
798799
assert(mode===BROTLI_DECODE||mode===BROTLI_ENCODE);
799800

800801
TypedArrayPrototypeFill(brotliInitParamsArray,-1);
801-
if(opts&&opts.params){
802-
for(constorigKeyofObjectKeys(opts.params)){
802+
if(opts?.params){
803+
ArrayPrototypeForEach(ObjectKeys(opts.params),(origKey)=>{
803804
constkey=+origKey;
804805
if(NumberIsNaN(key)||key<0||key>kMaxBrotliParam||
805806
(brotliInitParamsArray[key]|0)!==-1){
@@ -812,7 +813,7 @@ function Brotli(opts, mode) {
812813
'number',opts.params[origKey]);
813814
}
814815
brotliInitParamsArray[key]=value;
815-
}
816+
});
816817
}
817818

818819
consthandle=mode===BROTLI_DECODE ?

0 commit comments

Comments
 (0)