]> git.kaiwu.me - njs.git/commit
Fix reentrant object-to-primitive conversion
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 4 Sep 2026 01:48:39 +0000 (18:48 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 4 Sep 2026 21:53:08 +0000 (14:53 -0700)
commit9c20d77307a4bec4bd59b3535de28a328a18a402
treea693040e54f254722f017a4a41408cb9dbff46fd
parent7e4194c53303d222bdc77d0d742a71be298b8cf8
Fix reentrant object-to-primitive conversion

Previously, njs_value_to_primitive() retained a pointer to the caller's value
slot while valueOf(), toString(), or property getters executed user code.
Reentrant code could overwrite that slot, after which the conversion treated
the replacement primitive as the original object.

The fix is to snapshot the input value before the first observable property
lookup and use the stable copy throughout conversion.

The issue was introduced in 64dbf104 (0.3.4).

This closes #1094 issue on GitHub.
src/njs_value.c
src/test/njs_unit_test.c