fixed potential off-by-one buffer overflow bug when recording tapes
authorHolger Schemel <info@artsoft.org>
Wed, 10 Jan 2018 09:41:23 +0000 (10:41 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 10 Jan 2018 09:41:23 +0000 (10:41 +0100)
src/tape.c

index 831659b62cb881ac47353c1e37992d3917c8d57b..5e55cb0453fad9166df5de9c971aaba03950abfc 100644 (file)
@@ -641,7 +641,10 @@ void TapeHaltRecording()
     return;
 
   tape.counter++;
-  tape.pos[tape.counter].delay = 0;
+
+  // initialize delay for next tape entry (to be able to continue recording)
+  if (tape.counter < MAX_TAPE_LEN)
+    tape.pos[tape.counter].delay = 0;
 
   tape.length = tape.counter;
   tape.length_frames = GetTapeLengthFrames();