fixed memory leak in recently added "last played level sets" feature
authorHolger Schemel <info@artsoft.org>
Wed, 20 Jan 2021 23:02:14 +0000 (00:02 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 20 Jan 2021 23:02:34 +0000 (00:02 +0100)
src/libgame/setup.c

index 718259ef43bf46759021cbbe284cba7bed029462..478f214ff856b65ea7d7b95cfa96cde9b40917aa 100644 (file)
@@ -4508,7 +4508,7 @@ void LoadLevelSetup_LastSeries(void)
   leveldir_current = getFirstValidTreeInfoEntry(leveldir_first);
 
   // start with empty history of last played level sets
-  setup.level_setup.last_level_series[0] = NULL;
+  setString(&setup.level_setup.last_level_series[0], NULL);
 
   if (!strEqual(DEFAULT_LEVELSET, UNDEFINED_LEVELSET))
   {
@@ -4540,11 +4540,11 @@ void LoadLevelSetup_LastSeries(void)
       leveldir_last = getTreeInfoFromIdentifier(leveldir_first,
                                                last_level_series);
       if (leveldir_last != NULL)
-       setup.level_setup.last_level_series[pos++] =
-         getStringCopy(last_level_series);
+       setString(&setup.level_setup.last_level_series[pos++],
+                 last_level_series);
     }
 
-    setup.level_setup.last_level_series[pos] = NULL;
+    setString(&setup.level_setup.last_level_series[pos], NULL);
 
     freeSetupFileHash(level_setup_hash);
   }