Skip to content

Commit 9b5d7b1

Browse files
committed
util: use primordials consistently in comparisons.js
Replace native array.push() with ArrayPrototypePush in lib/internal/util/comparisons.js for consistency and security. This improves protection against prototype pollution and aligns with the primordials pattern used throughout the codebase.
1 parent 05d6b9b commit 9b5d7b1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/internal/util/comparisons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ function setEquiv(a, b, mode, memo) {
719719
// If the specified value doesn't exist in the second set it's a object
720720
// (or in loose mode: a non-matching primitive). Find the
721721
// deep-(mode-)equal element in a set copy to reduce duplicate checks.
722-
array.push(val);
722+
ArrayPrototypePush(array, val);
723723
}
724724
}
725725

@@ -843,7 +843,7 @@ function mapEquiv(a, b, mode, memo) {
843843
}
844844
array = [];
845845
}
846-
array.push(key2);
846+
ArrayPrototypePush(array, key2);
847847
} else {
848848
// By directly retrieving the value we prevent another b.has(key2) check in
849849
// almost all possible cases.
@@ -859,7 +859,7 @@ function mapEquiv(a, b, mode, memo) {
859859
if (array === undefined) {
860860
array = [];
861861
}
862-
array.push(key2);
862+
ArrayPrototypePush(array, key2);
863863
}
864864
}
865865
}

0 commit comments

Comments
 (0)