From ae14776a6c741f4751acba9ad68d9708aff20845 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 22 Jun 2024 10:55:07 +0200 Subject: [PATCH] Validate color index against colormap boundaries Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/Colormap-Overlay.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h b/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h index ac41ca3f8..e894b65ee 100644 --- a/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h +++ b/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h @@ -24,6 +24,7 @@ #include "kaleidoscope/key_defs.h" // for Key, KEY_FLAGS, Key_NoKey, LockLayer #include "kaleidoscope/layers.h" // for Layer, Layer_ #include "kaleidoscope/plugin/LEDControl.h" // for LEDControl +#include // for LEDPaletteTheme namespace kaleidoscope { namespace plugin { @@ -60,7 +61,8 @@ class ColormapOverlay : public kaleidoscope::Plugin { for (int layer_ = 0; layer_ < _layer_count; layer_++) { for (int key_index_ = 0; key_index_ < kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns; key_index_++) { int8_t color_index_ = overlays[layer_][key_index_]; - if (color_index_ != no_color_overlay) { + if (color_index_ >= 0 && color_index_ < ::LEDPaletteTheme.getPaletteSize() && + color_index_ != no_color_overlay) { overlays_[overlay_count_] = Overlay(layer_, KeyAddr(key_index_), color_index_); overlay_count_++; }