Merge pull request #418 from nickva/fix-byteoffset-for-detached-array-buffers

Fix byteOffset for detached array buffers
This commit is contained in:
bellard 2025-06-14 11:30:13 +02:00 committed by GitHub
commit 9b935dba42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 7 deletions

View File

@ -214,6 +214,7 @@ jobs:
submodules: true submodules: true
- name: Install MinGW and Wine - name: Install MinGW and Wine
run: | run: |
sudo apt update
sudo apt install -y wine mingw-w64 sudo apt install -y wine mingw-w64
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll . cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll .
- name: Setup Wine - name: Setup Wine

View File

@ -54017,7 +54017,8 @@ static JSValue js_typed_array_subarray(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv) int argc, JSValueConst *argv)
{ {
JSValueConst args[4]; JSValueConst args[4];
JSValue arr, byteOffset, ta_buffer; JSValue arr, ta_buffer;
JSTypedArray *ta;
JSObject *p; JSObject *p;
int len, start, final, count, shift, offset; int len, start, final, count, shift, offset;
@ -54034,12 +54035,10 @@ static JSValue js_typed_array_subarray(JSContext *ctx, JSValueConst this_val,
goto exception; goto exception;
} }
count = max_int(final - start, 0); count = max_int(final - start, 0);
byteOffset = js_typed_array_get_byteOffset(ctx, this_val, 0);
if (JS_IsException(byteOffset))
goto exception;
shift = typed_array_size_log2(p->class_id); shift = typed_array_size_log2(p->class_id);
offset = JS_VALUE_GET_INT(byteOffset) + (start << shift); ta = p->u.typed_array;
JS_FreeValue(ctx, byteOffset); /* Read byteOffset (ta->offset) even if detached */
offset = ta->offset + (start << shift);
ta_buffer = js_typed_array_get_buffer(ctx, this_val, 0); ta_buffer = js_typed_array_get_buffer(ctx, this_val, 0);
if (JS_IsException(ta_buffer)) if (JS_IsException(ta_buffer))
goto exception; goto exception;

View File

@ -23,7 +23,6 @@ test262/test/staging/sm/TypedArray/prototype-constructor-identity.js:17: Test262
test262/test/staging/sm/TypedArray/set-detached-bigint.js:27: Error: Assertion failed: expected exception SyntaxError, got RangeError: invalid array length test262/test/staging/sm/TypedArray/set-detached-bigint.js:27: Error: Assertion failed: expected exception SyntaxError, got RangeError: invalid array length
test262/test/staging/sm/TypedArray/set-detached.js:112: RangeError: invalid array length test262/test/staging/sm/TypedArray/set-detached.js:112: RangeError: invalid array length
test262/test/staging/sm/TypedArray/sort_modifications.js:12: Test262Error: Int8Array at index 0 for size 4 Expected SameValue(«0», «1») to be true test262/test/staging/sm/TypedArray/sort_modifications.js:12: Test262Error: Int8Array at index 0 for size 4 Expected SameValue(«0», «1») to be true
test262/test/staging/sm/TypedArray/subarray.js:15: Test262Error: Expected SameValue(«0», «1») to be true
test262/test/staging/sm/async-functions/async-contains-unicode-escape.js:45: Error: Assertion failed: expected exception SyntaxError, no exception thrown test262/test/staging/sm/async-functions/async-contains-unicode-escape.js:45: Error: Assertion failed: expected exception SyntaxError, no exception thrown
test262/test/staging/sm/async-functions/await-error.js:12: Test262Error: Expected SameValue(«false», «true») to be true test262/test/staging/sm/async-functions/await-error.js:12: Test262Error: Expected SameValue(«false», «true») to be true
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) => {}) => {} 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) => {}) => {}