]> git.kaiwu.me - njs.git/commitdiff
A fix in typeof function.
authorAndrey Zelenkov <zelenkov@nginx.com>
Thu, 20 Oct 2016 14:12:42 +0000 (17:12 +0300)
committerAndrey Zelenkov <zelenkov@nginx.com>
Thu, 20 Oct 2016 14:12:42 +0000 (17:12 +0300)
Found with afl-fuzz.

njs/njs_vm.c
njs/test/njs_unit_test.c

index 3443966b6b02ef7d7f8e4ae13f0d91c905813a8e..2b8ae555b3f5b7178a87241b602df02eaaeeffe6 100644 (file)
@@ -1444,6 +1444,7 @@ njs_vmcode_typeof(njs_vm_t *vm, njs_value_t *value, njs_value_t *invld)
         &njs_string_object,
         &njs_string_function,
         &njs_string_object,
+        &njs_string_object,
     };
 
     vm->retval = *types[value->type];
index 322a09dc204744eef21bb5ad53fb3be1afc6183e..86c31abbf076bbf85760b2b43b8b0e945747797e 100644 (file)
@@ -1795,6 +1795,9 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("typeof /./i"),
       nxt_string("object") },
 
+    { nxt_string("typeof Date.prototype"),
+      nxt_string("object") },
+
     { nxt_string("typeof a"),
       nxt_string("undefined") },