]> git.kaiwu.me - njs.git/commit
Honor source view offset in same-type copies
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 12 Jun 2026 01:59:36 +0000 (18:59 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 16 Jun 2026 23:22:57 +0000 (16:22 -0700)
commit210bd6b161a84930d4d6217086d5be7b51758a41
tree31ac90cc890afc42375b20798ea72bb4276b0b22
parent66c6cdf9e15d56bd9442716bd5c854d5f19d005b
Honor source view offset in same-type copies

The same-type fast paths in the typed array constructor, slice(),
toReversed() and toSorted() copied from the start of the source buffer
instead of the view base, ignoring the source view's byte offset.  For an
offset or subarray source they copied the wrong elements and could read
past the view into adjacent data.

Use njs_typed_array_start()/njs_typed_array_offset() for the copy source.
src/njs_typed_array.c
src/test/njs_unit_test.c