[njs] Fixed exception handling in arguments of a function.

Dmitry Volyntsev xeioex at nginx.com
Tue Aug 28 16:23:32 UTC 2018


details:   http://hg.nginx.org/njs/rev/0191fae31b6d
branches:  
changeset: 591:0191fae31b6d
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Aug 28 18:42:43 2018 +0300
description:
Fixed exception handling in arguments of a function.

diffstat:

 njs/njs_function.c       |  2 +-
 njs/test/njs_unit_test.c |  5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)

diffs (34 lines):

diff -r cfd82c5cfa93 -r 0191fae31b6d njs/njs_function.c
--- a/njs/njs_function.c	Tue Aug 28 15:37:14 2018 +0300
+++ b/njs/njs_function.c	Tue Aug 28 18:42:43 2018 +0300
@@ -216,6 +216,7 @@ njs_function_frame(njs_vm_t *vm, njs_fun
 
     frame = (njs_frame_t *) native_frame;
     frame->local = value;
+    frame->previous_active_frame = vm->active_frame;
 
     return NXT_OK;
 }
@@ -392,7 +393,6 @@ njs_function_call(njs_vm_t *vm, njs_inde
         vm->scopes[NJS_SCOPE_CLOSURE + n] = &closure->u.values;
     }
 
-    frame->previous_active_frame = vm->active_frame;
     vm->active_frame = frame;
 
     return NJS_APPLIED;
diff -r cfd82c5cfa93 -r 0191fae31b6d njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Tue Aug 28 15:37:14 2018 +0300
+++ b/njs/test/njs_unit_test.c	Tue Aug 28 18:42:43 2018 +0300
@@ -5907,6 +5907,11 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("try {}"),
       nxt_string("SyntaxError: Missing catch or finally after try in 1") },
 
+    { nxt_string("function f(a) {return a;}; "
+                 "function thrower() {throw TypeError('Oops')}; "
+                 "f(thrower())"),
+      nxt_string("TypeError: Oops") },
+
     { nxt_string("var a = 0; try { a = 5 }"
                  "catch (e) { a = 9 } finally { a++ } a"),
       nxt_string("6") },


More information about the nginx-devel mailing list