From e7f9edba2d78a75e90747a00758915a055a7c654 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Sat, 11 Nov 2017 23:46:08 -0600 Subject: [PATCH] Added a check to prevent reading past the end of the keymaps[] array This relys on the 'LayerCount' variable being correct and defined in the firmware sketch file (along with 'keymaps') --- src/layers.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/layers.cpp b/src/layers.cpp index 702672a8..88f43c80 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -125,6 +125,11 @@ void Layer_::move(uint8_t layer) { } void Layer_::on(uint8_t layer) { + if (layer >= LayerCount) { + // Trying to turn on a layer that doesn't exist; abort + return; + } + bool wasOn = isOn(layer); bitSet(LayerState, layer);