]> git.kaiwu.me - njs.git/commitdiff
Fixed try_break instruction.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 17 Jan 2019 13:11:52 +0000 (16:11 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 17 Jan 2019 13:11:52 +0000 (16:11 +0300)
njs/njs_vm.c
njs/test/njs_unit_test.c

index d182e70784ba9248aa56883949df9a6a11c281d7..fce24a97731441db2170ead8417341feab0f6fe8 100644 (file)
@@ -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;
 }
index d76e85dc79409a9a4282ad5a16daa30a979d7a58..2a456c9dc3da03dd62614e0b82a6ad28e17be35a 100644 (file)
@@ -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") },