]> git.kaiwu.me - njs.git/commit
Propertly handling NJS_DECLINE in promise native functions.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 16 Jun 2022 00:10:39 +0000 (17:10 -0700)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 16 Jun 2022 00:10:39 +0000 (17:10 -0700)
commitb403e2e83eb417e43c01707691b2092393d1911d
treeef69cc422b360f5eef0515876ac72118c613a7f2
parentaaa3249830fa04e859a60f36cc0f885f452d8e2e
Propertly handling NJS_DECLINE in promise native functions.

Previously, NJS_DECLINE was returned from a Promise.all() and friends
when "resolve" property was not found in a promise constructor.
NJS_DECLINE was treated as NJS_ERROR in one place, but as NJS_OK in a
different place during the promise function evaluation.  As a result,
the VM was left in inconsistent state during stack unwinding which
resulted in a garbage return value.

The fix is to ensure that only NJS_ERROR or NJS_OK is returned
from ordinary native functions.

This closes #545 issue on Github.
src/njs_promise.c
src/test/njs_unit_test.c