about summary refs log tree commit diff
path: root/HexBoard_V1.1.ino
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-09-18 12:34:40 -0400
committerZach DeCook <zachdecook@librem.one>2023-09-18 12:34:40 -0400
commit16a7523ef8f178f030da7e7264a88ed060e087b5 (patch)
tree86df4bd09e418cd330941fa572a1d9018f10eb67 /HexBoard_V1.1.ino
parentaec787a79191085f04c1c7ef83dabf152709487d (diff)
downloadHexBoard-16a7523ef8f178f030da7e7264a88ed060e087b5.tar.gz
Buzzer Tones: Don't do out-of-bounds array access
Diffstat (limited to 'HexBoard_V1.1.ino')
-rw-r--r--HexBoard_V1.1.ino4
1 files changed, 4 insertions, 0 deletions
diff --git a/HexBoard_V1.1.ino b/HexBoard_V1.1.ino
index b0f31f3..55d83df 100644
--- a/HexBoard_V1.1.ino
+++ b/HexBoard_V1.1.ino
@@ -1162,6 +1162,10 @@ byte getHeldNote() {
 }
 
 void do_tone(byte pitch) {
+    if (pitch > 127 || pitch < 0) {
+        noTone(TONEPIN);
+        return;
+    }
     if (tones == 12) {
         tone(TONEPIN, pitches[pitch]);
     } else if (tones == 19) {