Skip to content

Commit 362f63d

Browse files
committed
fix: check that indexes are in range for moving list elements
1 parent 3e7b013 commit 362f63d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • app/src/main/java/io/github/sds100/keymapper/util

app/src/main/java/io/github/sds100/keymapper/util/ListUtils.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import java.util.Collections
77
*/
88

99
fun MutableList<*>.moveElement(fromIndex: Int, toIndex: Int) {
10+
if (toIndex >= size || fromIndex >= size) {
11+
return
12+
}
13+
1014
if (fromIndex < toIndex) {
1115
for (i in fromIndex until toIndex) {
1216
Collections.swap(this, i, i + 1)

0 commit comments

Comments
 (0)