Skip to content

Commit 9b935db

Browse files
authored
Merge pull request bellard#418 from nickva/fix-byteoffset-for-detached-array-buffers
Fix byteOffset for detached array buffers
2 parents 638ec8c + 0f7eadf commit 9b935db

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ jobs:
214214
submodules: true
215215
- name: Install MinGW and Wine
216216
run: |
217+
sudo apt update
217218
sudo apt install -y wine mingw-w64
218219
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll .
219220
- name: Setup Wine

quickjs.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54017,7 +54017,8 @@ static JSValue js_typed_array_subarray(JSContext *ctx, JSValueConst this_val,
5401754017
int argc, JSValueConst *argv)
5401854018
{
5401954019
JSValueConst args[4];
54020-
JSValue arr, byteOffset, ta_buffer;
54020+
JSValue arr, ta_buffer;
54021+
JSTypedArray *ta;
5402154022
JSObject *p;
5402254023
int len, start, final, count, shift, offset;
5402354024

@@ -54034,12 +54035,10 @@ static JSValue js_typed_array_subarray(JSContext *ctx, JSValueConst this_val,
5403454035
goto exception;
5403554036
}
5403654037
count = max_int(final - start, 0);
54037-
byteOffset = js_typed_array_get_byteOffset(ctx, this_val, 0);
54038-
if (JS_IsException(byteOffset))
54039-
goto exception;
5404054038
shift = typed_array_size_log2(p->class_id);
54041-
offset = JS_VALUE_GET_INT(byteOffset) + (start << shift);
54042-
JS_FreeValue(ctx, byteOffset);
54039+
ta = p->u.typed_array;
54040+
/* Read byteOffset (ta->offset) even if detached */
54041+
offset = ta->offset + (start << shift);
5404354042
ta_buffer = js_typed_array_get_buffer(ctx, this_val, 0);
5404454043
if (JS_IsException(ta_buffer))
5404554044
goto exception;

test262_errors.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ test262/test/staging/sm/TypedArray/prototype-constructor-identity.js:17: Test262
2323
test262/test/staging/sm/TypedArray/set-detached-bigint.js:27: Error: Assertion failed: expected exception SyntaxError, got RangeError: invalid array length
2424
test262/test/staging/sm/TypedArray/set-detached.js:112: RangeError: invalid array length
2525
test262/test/staging/sm/TypedArray/sort_modifications.js:12: Test262Error: Int8Array at index 0 for size 4 Expected SameValue(«0», «1») to be true
26-
test262/test/staging/sm/TypedArray/subarray.js:15: Test262Error: Expected SameValue(«0», «1») to be true
2726
test262/test/staging/sm/async-functions/async-contains-unicode-escape.js:45: Error: Assertion failed: expected exception SyntaxError, no exception thrown
2827
test262/test/staging/sm/async-functions/await-error.js:12: Test262Error: Expected SameValue(«false», «true») to be true
2928
test262/test/staging/sm/async-functions/await-in-arrow-parameters.js:33: Error: Assertion failed: expected exception SyntaxError, no exception thrown - AsyncFunction:(a = (b = await/r/g) => {}) => {}

0 commit comments

Comments
 (0)