From 1aefca1baaf385d15c014247d3a5e489d13a6450 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 8 Oct 2021 16:23:46 +0200 Subject: fix index out of bounds crash --- main/main.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'main') diff --git a/main/main.ino b/main/main.ino index 67222ee..e084af1 100644 --- a/main/main.ino +++ b/main/main.ino @@ -1,5 +1,7 @@ #include "constants.h" +#define MIN(a, b) ((a) > (b) ? (b) : (a)) + /** BN (KB) -> PIN & PIN * 1 (0) -> D8 & D9 * 2 (1) -> D8 & D7 @@ -215,7 +217,8 @@ void kb_onevent(kb_event ev) { // voeg getal toe aan het einde van de code code[codei] = num; - codei++; //TODO: fix array out of bounds crash + codei++; + codei = MIN(codei, MAX_CODE_LEN - 1); } } } -- cgit v1.2.3