Skip to content

Commit 7f25deb

Browse files
fix: added input validation
1 parent ee58dae commit 7f25deb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/badge_animation/ani_snowflake.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,21 @@ class SnowFlakeAnimation extends BadgeAnimation {
99
List<List<bool>> processGrid,
1010
List<List<bool>> canvas,
1111
) {
12+
if (processGrid.isEmpty ||
13+
processGrid.any((row) => row.length != processGrid[0].length)) {
14+
throw ArgumentError(
15+
'processGrid must be a non-empty rectangular 2D list',
16+
);
17+
}
1218
int newGridHeight = processGrid.length;
1319
int newGridWidth = processGrid[0].length;
1420

21+
if (canvas.length < badgeHeight ||
22+
canvas.any((row) => row.length < badgeWidth)) {
23+
throw ArgumentError(
24+
'canvas must have at least $badgeHeight rows and $badgeWidth columns',
25+
);
26+
}
1527
int framesCount = (newGridWidth / badgeWidth).ceil();
1628
framesCount = framesCount == 0 ? 1 : framesCount;
1729

0 commit comments

Comments
 (0)