mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 970285 -- Detect negative lengths supplied to unsized array constructor r=shu
This commit is contained in:
parent
0fe7059394
commit
5ea9b4cfa5
@ -2427,6 +2427,11 @@ TypedObject::constructUnsized(JSContext *cx, unsigned int argc, Value *vp)
|
||||
// Length constructor.
|
||||
if (args[0].isInt32()) {
|
||||
int32_t length = args[0].toInt32();
|
||||
if (length < 0) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage,
|
||||
nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS);
|
||||
return nullptr;
|
||||
}
|
||||
Rooted<TypedObject*> obj(cx, createZeroed(cx, callee, length));
|
||||
if (!obj)
|
||||
return false;
|
||||
|
11
js/src/jit-test/tests/TypedObject/bug970285.js
Normal file
11
js/src/jit-test/tests/TypedObject/bug970285.js
Normal file
@ -0,0 +1,11 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
if (!this.hasOwnProperty("TypedObject"))
|
||||
throw new TypeError();
|
||||
|
||||
// Test that we detect invalid lengths supplied to unsized array
|
||||
// constructor. Public domain.
|
||||
|
||||
var AA = TypedObject.uint8.array(2147483647).array();
|
||||
var aa = new AA(-1);
|
||||
|
Loading…
Reference in New Issue
Block a user