]> git.kaiwu.me - njs.git/commit
TypedArray: coerce length argument once on buffer construction
authorbasavaraj-sm05 <basavaraj@digiscrypt.com>
Wed, 9 Sep 2026 06:56:41 +0000 (12:26 +0530)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 15 Sep 2026 21:18:20 +0000 (14:18 -0700)
commitfd8441bc71c566616176ace18caed62b8ac65cfa
tree92a1a62bb37dbac1d5ca30ef8937ac7e0f438fc9
parent5d06a8e8599c3a87c3c694374d603da72f151743
TypedArray: coerce length argument once on buffer construction

Previously, njs_typed_array_alloc() passed the length argument through
njs_value_to_index() twice, before and after the detached-buffer check,
and kept only the second result.  The argument's valueOf() was invoked
twice, which is observable.

The fix is to remove the second conversion.
src/njs_typed_array.c
src/test/njs_unit_test.c