From: hongzhidao Date: Mon, 18 Mar 2019 13:05:27 +0000 (+0300) Subject: Fixed native frame arguments number. X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=698d724bd7d87f7c5a821df316f616bcca69e775;p=njs.git Fixed native frame arguments number. --- diff --git a/njs/njs_function.c b/njs/njs_function.c index 09e4a9b3..afc8422f 100644 --- a/njs/njs_function.c +++ b/njs/njs_function.c @@ -310,6 +310,7 @@ njs_function_lambda_frame(njs_vm_t *vm, njs_function_t *function, } else { n = function->args_offset; + native_frame->nargs += n - 1; do { *value++ = *bound++; diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 32012846..135bb709 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -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") },