Fix potential out of bounds access

The preferred pos mechanism could cause an out of bounds access on 1 row
layouts.
This commit is contained in:
Jules Aguillon 2024-03-16 23:42:37 +01:00
parent e74b45c2d6
commit 0549c6c8a1

View File

@ -82,7 +82,7 @@ public final class KeyboardData
boolean add_key_to_pos(List<Row> rows, KeyValue kv, KeyPos p)
{
int i_row = p.row;
int i_row_end = p.row;
int i_row_end = Math.min(p.row, rows.size());
if (p.row == -1) { i_row = 0; i_row_end = rows.size() - 1; }
for (; i_row <= i_row_end; i_row++)
{