]> git.kaiwu.me - njs.git/commit
Fix the conversion of a property key to an array index
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 9 Sep 2026 01:44:05 +0000 (18:44 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 14 Sep 2026 17:53:52 +0000 (10:53 -0700)
commitfe25e5b3b09a832b707946e8c39a6d5c56d7fd82
tree03dcffae35aa4aa768da53cbb6b48ce70ad7de5f
parentcb07cee0bbba4d0612e1a44e0ab8f0e6c6b5e890
Fix the conversion of a property key to an array index

Previously, a double was converted to uint32_t before its range was tested,
so a property key that is NaN, negative or larger than 2^31 made the
conversion undefined.  UndefinedBehaviorSanitizer reported it for every VM
creation, where an environment variable name is atomized.

The fix is to test the range first and to share one njs_number_is_atom_index()
helper between the four places that repeated the pattern.
src/njs_atom.c
src/njs_number.h
src/njs_vmcode.c