From 9dc809d3e4800324c9cfca934ba3bf3c50a03b35 Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Thu, 30 May 2024 14:00:19 -0400 Subject: [PATCH] Validate array length when converting to `Matrix3`. --- src/lime/math/Matrix3.hx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lime/math/Matrix3.hx b/src/lime/math/Matrix3.hx index b9e42356a..4145b799d 100644 --- a/src/lime/math/Matrix3.hx +++ b/src/lime/math/Matrix3.hx @@ -22,7 +22,7 @@ import lime.utils.Float32Array; @:fileXml('tags="haxe,release"') @:noDebug #end -abstract Matrix3(Float32Array) from Float32Array to Float32Array +abstract Matrix3(Float32Array) to Float32Array { /** The matrix a component, used in scaling and skewing (default is 1) @@ -335,6 +335,16 @@ abstract Matrix3(Float32Array) from Float32Array to Float32Array return new Matrix3(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); } + @:from private static inline function fromFloat32Array(array:Float32Array):Matrix3 + { + if (array.length != 9) + { + throw "Expected array of length 9, got " + array.length; + } + + return cast array; + } + /** Resets the matrix to default identity values **/