fixed potential off-by-one buffer overflow bug when recording tapes
[rocksndiamonds.git] / 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();