diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-10-08 16:23:46 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-10-08 16:23:46 +0200 |
commit | 1aefca1baaf385d15c014247d3a5e489d13a6450 (patch) | |
tree | 70ef611d2c6ff1bc268ba10dd94f212d7a708f54 /main | |
parent | 334cd04bfcf17cdfd4035e53ec08316401c1f17d (diff) |
fix index out of bounds crash
Diffstat (limited to 'main')
-rw-r--r-- | main/main.ino | 5 |
1 files changed, 4 insertions, 1 deletions
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); } } } |