Skip to content

Commit 02feba6

Browse files
committed
fixup! perf_hooks: fix stack overflow error
1 parent d5b5e37 commit 02feba6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/internal/per_context/primordials.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,16 @@ primordials.SafeStringPrototypeSearch = (str, regexp) => {
731731
* @returns {ReturnType<typeof Array.prototype.push>}
732732
*/
733733
primordials.SafeArrayPrototypePushApply = (arr, items) => {
734-
let start = 0;
735734
let end = 0x10000;
736-
while (end < items.length) {
737-
ArrayPrototypePushApply(arr, ArrayPrototypeSlice(items, start, start = end));
738-
end += 0x10000;
735+
if (end < items.length) {
736+
let start = 0;
737+
do {
738+
ArrayPrototypePushApply(arr, ArrayPrototypeSlice(items, start, start = end));
739+
end += 0x10000;
740+
} while (end < items.length);
741+
items = ArrayPrototypeSlice(items, start);
739742
}
740-
return ArrayPrototypePushApply(arr, ArrayPrototypeSlice(items, start));
743+
return ArrayPrototypePushApply(arr, items);
741744
};
742745

743746
ObjectSetPrototypeOf(primordials, null);

0 commit comments

Comments
 (0)