avm2: Throw error for invalid Stage3D back buffer size

This commit is contained in:
Aaron Hill 2023-05-10 14:49:17 -05:00
parent 82c61b5a52
commit 75569e1311
6 changed files with 63 additions and 1 deletions

View File

@ -1,4 +1,4 @@
use crate::avm2::error::make_error_2008;
use crate::avm2::error::{error, make_error_2008};
use crate::avm2::parameters::ParametersExt;
use crate::avm2::Activation;
use crate::avm2::TObject;
@ -58,6 +58,22 @@ pub fn configure_back_buffer<'gc>(
let width = args.get_u32(activation, 0)?;
let height = args.get_u32(activation, 1)?;
if width < 32 || width > 16384 {
return Err(Error::AvmError(error(
activation,
"Error #3780: Requested width of backbuffer is not in allowed range 32 to 16384.",
3780,
)?));
}
if height < 32 || height > 16384 {
return Err(Error::AvmError(error(
activation,
"Error #3781: Requested height of backbuffer is not in allowed range 32 to 16384.",
3781,
)?));
}
let anti_alias = args.get_u32(activation, 2)?;
let enable_depth_and_stencil = args.get(3).unwrap_or(&Value::Undefined).coerce_to_boolean();
let wants_best_resolution = args.get(4).unwrap_or(&Value::Undefined).coerce_to_boolean();

View File

@ -0,0 +1,38 @@
package {
import flash.display.MovieClip;
import flash.display.Stage3D;
import flash.events.Event;
public class Test {
public function Test(main:MovieClip) {
main.stage.stage3Ds[0].addEventListener(Event.CONTEXT3D_CREATE, function(event) {
var stage3d : Stage3D = event.target as Stage3D;
try {
stage3d.context3D.configureBackBuffer(0, 200, 0);
} catch (e) {
trace("Caught error: " + e);
}
try {
stage3d.context3D.configureBackBuffer(200, 0, 0);
} catch (e) {
trace("Caught error: " + e);
}
try {
stage3d.context3D.configureBackBuffer(999999999, 200, 0);
} catch (e) {
trace("Caught error: " + e);
}
try {
stage3d.context3D.configureBackBuffer(200, 999999999, 0);
} catch (e) {
trace("Caught error: " + e);
}
})
main.stage.stage3Ds[0].requestContext3D();
}
}
}

View File

@ -0,0 +1,4 @@
Caught error: Error: Error #3780: Requested width of backbuffer is not in allowed range 32 to 16384.
Caught error: Error: Error #3781: Requested height of backbuffer is not in allowed range 32 to 16384.
Caught error: Error: Error #3780: Requested width of backbuffer is not in allowed range 32 to 16384.
Caught error: Error: Error #3781: Requested height of backbuffer is not in allowed range 32 to 16384.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,4 @@
num_frames = 10
[player_options]
with_renderer = { optional = false, sample_count = 1 }