Skip to content

Commit f45e4f0

Browse files
committed
Fix Object.freeze on RAB-backed typed arrays (#856)
1 parent 51284bc commit f45e4f0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

quickjs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37126,6 +37126,8 @@ static JSValue js_object_seal(JSContext *ctx, JSValue this_val,
3712637126
{
3712737127
JSValue obj = argv[0];
3712837128
JSObject *p;
37129+
JSTypedArray *ta;
37130+
JSArrayBuffer *abuf;
3712937131
JSPropertyEnum *props;
3713037132
uint32_t len, i;
3713137133
int flags, desc_flags, res;
@@ -37146,6 +37148,13 @@ static JSValue js_object_seal(JSContext *ctx, JSValue this_val,
3714637148
return JS_ThrowTypeError(ctx, "proxy preventExtensions handler returned false");
3714737149
}
3714837150

37151+
if (freeze_flag && is_typed_array(p->class_id)) {
37152+
ta = p->u.typed_array;
37153+
abuf = ta->buffer->u.array_buffer;
37154+
if (array_buffer_is_resizable(abuf) || typed_array_is_oob(p))
37155+
return JS_ThrowTypeError(ctx, "cannot freeze resizable typed array");
37156+
}
37157+
3714937158
flags = JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK;
3715037159
if (JS_GetOwnPropertyNamesInternal(ctx, &props, &len, p, flags))
3715137160
return JS_EXCEPTION;

test262_errors.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ test262/test/built-ins/Object/defineProperty/coerced-P-shrink.js:16: Test262Erro
3030
test262/test/built-ins/Object/defineProperty/coerced-P-shrink.js:16: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
3131
test262/test/built-ins/Object/defineProperty/typedarray-backed-by-resizable-buffer.js:18: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
3232
test262/test/built-ins/Object/defineProperty/typedarray-backed-by-resizable-buffer.js:18: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
33-
test262/test/built-ins/Object/freeze/typedarray-backed-by-resizable-buffer.js:14: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
34-
test262/test/built-ins/Object/freeze/typedarray-backed-by-resizable-buffer.js:14: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
3533
test262/test/built-ins/RegExp/prototype/exec/regexp-builtin-exec-v-u-flag.js:45: Test262Error: Actual argument shouldn't be nullish. Unicode property escapes with v flag
3634
test262/test/built-ins/RegExp/prototype/exec/regexp-builtin-exec-v-u-flag.js:45: strict mode: Test262Error: Actual argument shouldn't be nullish. Unicode property escapes with v flag
3735
test262/test/built-ins/RegExp/unicodeSets/generated/rgi-emoji-16.0.js:16: Test262Error: `\p{RGI_Emoji}` should match 🇨🇶 (U+01F1E8 U+01F1F6)

0 commit comments

Comments
 (0)