From 56dbb2dfb65431b9b964499ed3826a7a7e49a842 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 4 Mar 2024 21:02:41 -0800 Subject: [PATCH] A couple more cases where Dynamic Macros could get itself stuck in a nearly-infinite loop with bad data. --- .../src/kaleidoscope/plugin/DynamicMacros.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp b/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp index 31f27ea0a2..32c2034a8d 100644 --- a/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp +++ b/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp @@ -76,7 +76,7 @@ uint8_t DynamicMacros::updateDynamicMacroCache() { uint8_t keyCode, flags; do { keyCode = Runtime.storage().read(pos++); - } while (keyCode != 0); + } while ((pos < (storage_base_ + storage_size_)) && keyCode != 0); break; } @@ -170,7 +170,7 @@ void DynamicMacros::play(uint8_t macro_id) { while (true) { key.setFlags(isKeycodeSequence ? 0 : storage.read(pos++)); key.setKeyCode(storage.read(pos++)); - if (key == Key_NoKey) + if (key == Key_NoKey || pos >= storage_base_ + storage_size_) break; tap(key); delay(interval);