]> git.kaiwu.me - njs.git/commit
Fix Array.prototype.slice() of large arrays in the non-fast keys path
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 12 Jun 2026 01:44:01 +0000 (18:44 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 16 Jun 2026 23:22:57 +0000 (16:22 -0700)
commit66c6cdf9e15d56bd9442716bd5c854d5f19d005b
tree9f7644ccfc232a8d1c66754ea75c7839c0869e84
parenta404538a67ee61f7652c4d450d658e6e156081a4
Fix Array.prototype.slice() of large arrays in the non-fast keys path

When the slice result length was 32761 or more, the destination array was
non-fast and slice_copy() reached the keys path, which enumerated every
own index of the source and copied each at its original key, ignoring the
requested [start, start + length) window and the destination-relative
position.  Array.prototype.slice() thus returned wrong results for such
arrays.

Filter the enumerated keys to the window and write them at index - start,
matching the fast-array path.

While here, also remove dead fast object path in slice_copy.
src/njs_array.c
src/test/njs_unit_test.c