Skip to content

Commit

Permalink
Added missing element in typeof table for DataView() type.
Browse files Browse the repository at this point in the history
Previously, typeof operation for DataView object resulted
in out of bounds array accessing.

This fixes #450 issue on Github.
  • Loading branch information
drsm committed Dec 24, 2021
1 parent 61c91f5 commit d457c95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/njs_vmcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions src/test/njs_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]") },

Expand Down

0 comments on commit d457c95

Please # to comment.