fixed crash bug when accessing invalid change page for broken level files
authorHolger Schemel <info@artsoft.org>
Sat, 27 Aug 2022 08:54:07 +0000 (10:54 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 27 Aug 2022 09:21:53 +0000 (11:21 +0200)
Thanks to Quipyowert for finding and fixing this bug!

src/files.c

index 09e3b4d2256fcfe7d7cee4b6c655070f57aee90b..45f4097f85f734dcb3645116b2bd616285a48726 100644 (file)
@@ -3355,6 +3355,10 @@ static int LoadLevel_CUSX(File *file, int chunk_size, struct LevelInfo *level)
 
   while (!checkEndOfFile(file))
   {
+    // level file might contain invalid change page number
+    if (xx_current_change_page >= ei->num_change_pages)
+      break;
+
     struct ElementChangeInfo *change = &ei->change_page[xx_current_change_page];
 
     xx_change = *change;       // copy change data into temporary buffer