From 38cbb8b0deea85f3590178b0c8640ac37ec4de7a Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Tue, 20 Jun 2017 17:12:44 +0300 Subject: [PATCH] Fixed Object.prototype.isPrototypeOf() without arguments. --- njs/njs_object.c | 2 +- njs/test/njs_unit_test.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/njs/njs_object.c b/njs/njs_object.c index dcad7939..caf7bb41 100644 --- a/njs/njs_object.c +++ b/njs/njs_object.c @@ -1413,7 +1413,7 @@ njs_object_prototype_is_prototype_of(njs_vm_t *vm, njs_value_t *args, retval = &njs_string_false; - if (njs_is_object(&args[0]) && njs_is_object(&args[1])) { + if (nargs > 1 && njs_is_object(&args[0]) && njs_is_object(&args[1])) { proto = args[0].data.u.object; object = args[1].data.u.object; diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 7055c9cd..6a0960a9 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -6030,6 +6030,9 @@ static njs_unit_test_t njs_test[] = "o.isPrototypeOf()"), nxt_string("false") }, + { nxt_string("Object.valueOf.isPrototypeOf()"), + nxt_string("false") }, + { nxt_string("var p = {}; var o = Object.create(p);" "o.isPrototypeOf(1)"), nxt_string("false") }, -- 2.47.3