]> git.kaiwu.me - njs.git/commitdiff
Added missing element in typeof table for DataView() type.
authorArtem S. Povalyukhin <artem.povaluhin@gmail.com>
Fri, 24 Dec 2021 07:00:15 +0000 (10:00 +0300)
committerArtem S. Povalyukhin <artem.povaluhin@gmail.com>
Fri, 24 Dec 2021 07:00:15 +0000 (10:00 +0300)
Previously, typeof operation for DataView object resulted
in out of bounds array accessing.

This fixes #450 issue on Github.

src/njs_vmcode.c
src/test/njs_unit_test.c

index 5facef586ac7c4befe0d8ed718f767575752f232..7591125504f17ee88dfb2504a2bfc4c80ca9a458 100644 (file)
@@ -1516,6 +1516,7 @@ njs_vmcode_typeof(njs_vm_t *vm, njs_value_t *value, njs_value_t *invld)
         &njs_string_object,
         &njs_string_object,
         &njs_string_object,
+        &njs_string_object,
     };
 
     vm->retval = *types[value->type];
index c8440d12978d1e54b4162c4c45b69ee4cc3d7ad3..7470b4bd674b0f318e3a3ff73782f9bf2a315725 100644 (file)
@@ -6390,6 +6390,9 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("(new DataView(new ArrayBuffer(3)))"),
       njs_str("[object DataView]") },
 
+    { njs_str("var x = new ArrayBuffer(3); [typeof x, typeof new DataView(x)]"),
+      njs_str("object,object") },
+
     { njs_str("(new DataView(new ArrayBuffer(3))).buffer"),
       njs_str("[object ArrayBuffer]") },