avm2: Handle wrong number of coords when drawing triangles in Graphics

FP throws an error when the number of coordinates is odd for the indexed
version, and when is not divisible by 6 for the non-indexed version.
This commit is contained in:
Kamil Jarosz 2024-06-17 21:09:07 +02:00
parent 86a3086808
commit 14ac29e435
1 changed files with 8 additions and 0 deletions

View File

@ -998,6 +998,10 @@ fn draw_triangles_internal<'gc>(
.expect("vertices is not a Vector"); .expect("vertices is not a Vector");
if let Some(indices) = indices { if let Some(indices) = indices {
if vertices.length() % 2 != 0 {
return Err(make_error_2004(activation, Error2004Type::ArgumentError));
}
let indices = indices let indices = indices
.as_vector_storage() .as_vector_storage()
.expect("indices is not a Vector"); .expect("indices is not a Vector");
@ -1050,6 +1054,10 @@ fn draw_triangles_internal<'gc>(
draw_triangle_internal(triangle, drawing, culling); draw_triangle_internal(triangle, drawing, culling);
} }
} else { } else {
if vertices.length() % 6 != 0 {
return Err(make_error_2004(activation, Error2004Type::ArgumentError));
}
let mut vertices = vertices.iter(); let mut vertices = vertices.iter();
fn read_point<'gc>( fn read_point<'gc>(