From edf3bc326c559852258fd251e9c1f07e65565a19 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Sun, 26 Jun 2022 16:19:15 +0900 Subject: [PATCH] Avoid userland re-entrance after a read in `Float16Array#spliced` https://github.com/tc39/proposal-change-array-by-copy/pull/89 --- src/Float16Array.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Float16Array.mjs b/src/Float16Array.mjs index f884fb41..c37fddc6 100644 --- a/src/Float16Array.mjs +++ b/src/Float16Array.mjs @@ -1044,6 +1044,11 @@ export class Float16Array { } const insertCount = items.length; + const converedItems = []; + for (let i = 0; i < insertCount; ++i) { + converedItems[i] = ToNumber(items[i]); + } + let actualDeleteCount; switch (arguments.length) { case 0: @@ -1081,7 +1086,7 @@ export class Float16Array { } for (let i = 0; i < insertCount; ++i) { - array[k] = roundToFloat16Bits(items[i]); + array[k] = roundToFloat16Bits(converedItems[i]); ++k; }