Skip to content

Commit

Permalink
Validate color index against colormap boundaries
Browse files Browse the repository at this point in the history
Signed-off-by: Evy Bongers <[email protected]>
  • Loading branch information
EvyBongers authored and obra committed Aug 7, 2024
1 parent 198155b commit ae14776
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Kaleidoscope-LED-Palette-Theme.h> // for LEDPaletteTheme

namespace kaleidoscope {
namespace plugin {
Expand Down Expand Up @@ -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_++;
}
Expand Down

0 comments on commit ae14776

Please sign in to comment.