[njs] Fixed Object.prototype.isPrototypeOf() without arguments.

Dmitry Volyntsev xeioex at nginx.com
Tue Jun 20 14:19:37 UTC 2017


details:   http://hg.nginx.org/njs/rev/1c4d7281d44e
branches:  
changeset: 372:1c4d7281d44e
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Jun 20 17:12:44 2017 +0300
description:
Fixed Object.prototype.isPrototypeOf() without arguments.

diffstat:

 njs/njs_object.c         |  2 +-
 njs/test/njs_unit_test.c |  3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r bcd7a7256805 -r 1c4d7281d44e njs/njs_object.c
--- a/njs/njs_object.c	Mon Jun 19 14:46:46 2017 +0300
+++ b/njs/njs_object.c	Tue Jun 20 17:12:44 2017 +0300
@@ -1413,7 +1413,7 @@ njs_object_prototype_is_prototype_of(njs
 
     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 -r bcd7a7256805 -r 1c4d7281d44e njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Mon Jun 19 14:46:46 2017 +0300
+++ b/njs/test/njs_unit_test.c	Tue Jun 20 17:12:44 2017 +0300
@@ -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") },


More information about the nginx-devel mailing list