[njs] Fixed try_break instruction.

Dmitry Volyntsev xeioex at nginx.com
Thu Jan 17 14:03:22 UTC 2019


details:   https://hg.nginx.org/njs/rev/9973704e2e36
branches:  
changeset: 730:9973704e2e36
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu Jan 17 16:11:52 2019 +0300
description:
Fixed try_break instruction.

diffstat:

 njs/njs_vm.c             |  5 ++++-
 njs/test/njs_unit_test.c |  3 +++
 2 files changed, 7 insertions(+), 1 deletions(-)

diffs (28 lines):

diff -r 0f919fb820e8 -r 9973704e2e36 njs/njs_vm.c
--- a/njs/njs_vm.c	Wed Jan 16 18:58:23 2019 +0300
+++ b/njs/njs_vm.c	Thu Jan 17 16:11:52 2019 +0300
@@ -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 -r 0f919fb820e8 -r 9973704e2e36 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Wed Jan 16 18:58:23 2019 +0300
+++ b/njs/test/njs_unit_test.c	Thu Jan 17 16:11:52 2019 +0300
@@ -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") },
 


More information about the nginx-devel mailing list