Layer_::updateKeyCache: Guard against out of bounds key coordinates

It may happen that we get passed an UNKNOWN_KEYSWITCH_LOCATION, which will
always be out of bounds. Lets not corrupt random memory when in this situation,
but instead, return quickly.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/161/head
Gergely Nagy 7 years ago
parent 8b9fdaa90f
commit 84768d505c

@ -84,6 +84,9 @@ void
Layer_::updateKeyCache(byte row, byte col) { Layer_::updateKeyCache(byte row, byte col) {
int8_t layer = highestLayer; int8_t layer = highestLayer;
if (row >= ROWS || col >= COLS)
return;
for (layer = highestLayer; layer >= DefaultLayer; layer--) { for (layer = highestLayer; layer >= DefaultLayer; layer--) {
if (Layer.isOn(layer)) { if (Layer.isOn(layer)) {
Key mappedKey = (*getKey)(layer, row, col); Key mappedKey = (*getKey)(layer, row, col);

Loading…
Cancel
Save