From: Dmitry Volyntsev Date: Thu, 17 Jan 2019 13:11:52 +0000 (+0300) Subject: Fixed try_break instruction. X-Git-Tag: 0.2.8~72 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=c275a5efe49cd6f521f3ed4cf0c83b30372a5e61;p=njs.git Fixed try_break instruction. --- diff --git a/njs/njs_vm.c b/njs/njs_vm.c index d182e707..fce24a97 100644 --- a/njs/njs_vm.c +++ b/njs/njs_vm.c @@ -2376,7 +2376,10 @@ nxt_noinline njs_ret_t njs_vmcode_try_break(njs_vm_t *vm, njs_value_t *exit_value, njs_value_t *offset) { - exit_value->data.u.number = 1; + /* exit_value can contain valid value set by vmcode_try_return. */ + if (!njs_is_valid(exit_value)) { + exit_value->data.u.number = 1; + } return (njs_ret_t) offset; } diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index d76e85dc..2a456c9d 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -6902,6 +6902,9 @@ static njs_unit_test_t njs_test[] = "})(function () {throw 'a'}, 'v')"), nxt_string("v") }, + { nxt_string("(function() { try { return ['a'];} finally {} } )()"), + nxt_string("a") }, + { nxt_string("var o = { valueOf: function() { return '3' } }; --o"), nxt_string("2") },