fixed potential crash bug when processing manipulated tape files
[rocksndiamonds.git] / src / tape.c
index 0c99d6802582ae5376635c932f585a5da959045f..449e79601bd399949549390286a977873d581ac8 100644 (file)
@@ -312,7 +312,8 @@ static void DrawVideoDisplay_DateTime(unsigned int state, unsigned int value)
       char s[MAX_DATETIME_STRING_SIZE];
       int year2 = value / 10000;
       int year4 = (year2 < 70 ? 2000 + year2 : 1900 + year2);
-      int month_index = (value / 100) % 100;
+      int month_index_raw = (value / 100) % 100;
+      int month_index = month_index_raw % 12;  // prevent invalid index
       int month = month_index + 1;
       int day = value % 100;