]> git.kaiwu.me - njs.git/commit
RegExp: fix cleanup of custom exec results
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 4 Sep 2026 01:47:58 +0000 (18:47 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 4 Sep 2026 21:53:08 +0000 (14:53 -0700)
commitc785b5722504d05935c56f7a27254f2b73f7927b
tree5ad0f958cabe1f24cfe55ab311616a6baea7e1ad
parent186c53d0f8430e4b7e775a857d0fefb185a69023
RegExp: fix cleanup of custom exec results

Previously, RegExp.prototype[Symbol.replace]() and Symbol.split() used
non-NULL exotic slots as proof that an exec() result was an internally
allocated match array.  A custom exec() could return any exotic object, which
was then cast to an array and freed, corrupting unrelated VM state.

The fix is to record whether RegExpBuiltinExec produced each result and to
release only fresh builtin results that could not escape through user code.

The replace issue was introduced in f7813172 (0.8.2), and the split issue was
introduced in aa697e3e (0.8.2).

This closes #1090, #1091, #1092, #1093, #1096, and #1097 issues on GitHub.
src/njs_regexp.c
src/test/njs_unit_test.c