From c275a5efe49cd6f521f3ed4cf0c83b30372a5e61 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Thu, 17 Jan 2019 16:11:52 +0300 Subject: [PATCH] Fixed try_break instruction. --- njs/njs_vm.c | 5 ++++- njs/test/njs_unit_test.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) 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") }, -- 2.47.3