Welcome! Log In Create A New Profile

Advanced

[njs] Fixed %TypedArray%.prototype.copyWithin() with nonzero byte offset.

Dmitry Volyntsev
June 05, 2020 08:02AM
details: https://hg.nginx.org/njs/rev/790bde011274
branches:
changeset: 1425:790bde011274
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Fri Jun 05 11:42:41 2020 +0000
description:
Fixed %TypedArray%.prototype.copyWithin() with nonzero byte offset.

diffstat:

src/njs_typed_array.c | 4 ++--
src/test/njs_unit_test.c | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r 23df5a31bafd -r 790bde011274 src/njs_typed_array.c
--- a/src/njs_typed_array.c Fri Jun 05 11:42:40 2020 +0000
+++ b/src/njs_typed_array.c Fri Jun 05 11:42:41 2020 +0000
@@ -803,8 +803,8 @@ njs_typed_array_prototype_copy_within(nj
buffer = njs_typed_array_buffer(array);
element_size = njs_typed_array_element_size(array->type);

- to = to * element_size;
- from = from * element_size;
+ to = (to + array->offset) * element_size;
+ from = (from + array->offset) * element_size;
count = count * element_size;

memmove(&buffer->u.u8[to], &buffer->u.u8[from], count);
diff -r 23df5a31bafd -r 790bde011274 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Fri Jun 05 11:42:40 2020 +0000
+++ b/src/test/njs_unit_test.c Fri Jun 05 11:42:41 2020 +0000
@@ -5720,6 +5720,13 @@ static njs_unit_test_t njs_test[] =
njs_str("true") },

{ njs_str(NJS_TYPED_ARRAY_LIST
+ ".every(v=>{var orig = new v([255,255,1,2,3,4,5]);"
+ " var a = new v(orig.buffer, 2* v.BYTES_PER_ELEMENT);"
+ " a.copyWithin(0,3);"
+ " return a.toString() === '4,5,3,4,5'})"),
+ njs_str("true") },
+
+ { njs_str(NJS_TYPED_ARRAY_LIST
".every(v=>{var a = new v([]); a.sort(); "
" return a.toString() === ''})"),
njs_str("true") },
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed %TypedArray%.prototype.copyWithin() with nonzero byte offset.

Dmitry Volyntsev 258 June 05, 2020 08:02AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 277
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready