Welcome! Log In Create A New Profile

Advanced

[njs] Fixed native frame arguments number.

Dmitry Volyntsev
March 18, 2019 09:52AM
details: https://hg.nginx.org/njs/rev/8868eed51544
branches:
changeset: 832:8868eed51544
user: hongzhidao <hongzhidao@gmail.com>
date: Mon Mar 18 16:05:27 2019 +0300
description:
Fixed native frame arguments number.

diffstat:

njs/njs_function.c | 1 +
njs/test/njs_unit_test.c | 11 +++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)

diffs (39 lines):

diff -r 9a87bf103c47 -r 8868eed51544 njs/njs_function.c
--- a/njs/njs_function.c Sun Mar 17 21:22:30 2019 +0800
+++ b/njs/njs_function.c Mon Mar 18 16:05:27 2019 +0300
@@ -310,6 +310,7 @@ njs_function_lambda_frame(njs_vm_t *vm,

} else {
n = function->args_offset;
+ native_frame->nargs += n - 1;

do {
*value++ = *bound++;
diff -r 9a87bf103c47 -r 8868eed51544 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Sun Mar 17 21:22:30 2019 +0800
+++ b/njs/test/njs_unit_test.c Mon Mar 18 16:05:27 2019 +0300
@@ -6306,6 +6306,14 @@ static njs_unit_test_t njs_test[] =
"var b = f.bind('1', '2', '3'); b.apply()"),
nxt_string("123") },

+ { nxt_string("var obj = {prop:'abc'}; "
+ "var func = function(x) { "
+ " return this === obj && x === 1 && arguments[0] === 1 "
+ " && arguments.length === 1 && this.prop === 'abc';"
+ "};"
+ "Function.prototype.bind.call(func, obj, 1)()"),
+ nxt_string("true") },
+
{ nxt_string("function F(a, b) { this.a = a + b }"
"var o = new F(1, 2);"
"o.a"),
@@ -6457,6 +6465,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("(function(){arguments.length = 1; return arguments.length;})(1,2,3)"),
nxt_string("1") },

+ { nxt_string("(function(){return arguments[3];}).bind(null, 0)('a','b','c')"),
+ nxt_string("c") },
+
{ nxt_string("(function(){return arguments.callee;})()"),
nxt_string("TypeError: \"caller\", \"callee\" properties may not be accessed") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed native frame arguments number.

Dmitry Volyntsev 62 March 18, 2019 09:52AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 85
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready