avm2: `new Array()` should reject negative and `NaN` length arguments as errors.

This commit is contained in:
David Wendt 2020-09-14 19:21:14 -04:00 committed by Mike Welsh
parent 582df3bd7d
commit e581704559
1 changed files with 4 additions and 0 deletions

View File

@ -28,6 +28,10 @@ pub fn instance_init<'gc>(
.get(0)
.and_then(|v| v.as_number(activation.context.gc_context).ok())
{
if expected_len < 0.0 || expected_len.is_nan() {
return Err("Length must be a positive integer".into());
}
array.set_length(expected_len as usize);
return Ok(Value::Undefined);