From 14ac29e43590d77287c5fc0786a5d9640e6e780a Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Mon, 17 Jun 2024 21:09:07 +0200 Subject: [PATCH] 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. --- core/src/avm2/globals/flash/display/graphics.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/avm2/globals/flash/display/graphics.rs b/core/src/avm2/globals/flash/display/graphics.rs index 75d41a059..2707c9093 100644 --- a/core/src/avm2/globals/flash/display/graphics.rs +++ b/core/src/avm2/globals/flash/display/graphics.rs @@ -998,6 +998,10 @@ fn draw_triangles_internal<'gc>( .expect("vertices is not a Vector"); if let Some(indices) = indices { + if vertices.length() % 2 != 0 { + return Err(make_error_2004(activation, Error2004Type::ArgumentError)); + } + let indices = indices .as_vector_storage() .expect("indices is not a Vector"); @@ -1050,6 +1054,10 @@ fn draw_triangles_internal<'gc>( draw_triangle_internal(triangle, drawing, culling); } } else { + if vertices.length() % 6 != 0 { + return Err(make_error_2004(activation, Error2004Type::ArgumentError)); + } + let mut vertices = vertices.iter(); fn read_point<'gc>(