Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -56436,6 +56436,10 @@ static JSValue js_typed_array_constructor_ta(JSContext *ctx,
JS_ThrowTypeErrorArrayBufferOOB(ctx);
goto fail;
}
if (len > p->u.array.count) {
JS_ThrowRangeError(ctx, "length out of bounds");
goto fail;
}
ta = p->u.typed_array;
src_buffer = ta->buffer;
src_abuf = src_buffer->u.array_buffer;
Expand Down
26 changes: 26 additions & 0 deletions tests/bug1305.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {assert} from "./assert.js"

const rab = new ArrayBuffer(10, { maxByteLength: 10 });
const src = new Uint8Array(rab, 0);

function f() {
return 1337;
}

const EvilConstructor = new Proxy(function(){}, {
get: function(target, prop, receiver) {
if (prop === 'prototype') {
print("resizing");
rab.resize(0);
return Uint8Array.prototype;
}
return Reflect.get(target, prop, receiver);
}
});

try {
let u8 = Reflect.construct(Uint8Array, [src], EvilConstructor);
print(u8);
} catch (e) {
assert(e instanceof RangeError);
}