]> git.kaiwu.me - njs.git/commit
Shell: fix unhandled rejection report in QuickJS
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 25 Sep 2026 05:07:14 +0000 (22:07 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 29 Sep 2026 18:57:53 +0000 (11:57 -0700)
commit82697e083439d3f7d662a03c85184ba0a5696161
tree0d534e01398018f9894e25f2bc8f7618ab1e239d
parent543995a05b6a7c4dbca873c592738f4eb44b1699
Shell: fix unhandled rejection report in QuickJS

Previously, njs_engine_qjs_unhandled_rejection() kept a pointer to
the rejected promise list while converting the first rejection reason
to a string.  The conversion may call user JavaScript code, which can
reject more promises and cause the list to be reallocated.  After that,
the old pointer was used together with the new item count to free the
promise and reason values, which caused out-of-bounds reads and invalid
frees.

The fix is to take a reference to the first reason and free the list
before conversion, so that rejections created during conversion are
tracked in a new list.

The test/js/promise_rejection_tracker_recursive.t.js test is no longer
skipped for the QuickJS engine.
auto/make
external/njs_shell.c
test/shell_test.exp