fixed potential crash bug if personal user level set cannot be found
authorHolger Schemel <info@artsoft.org>
Mon, 10 Feb 2020 22:21:35 +0000 (23:21 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 19 May 2020 16:12:55 +0000 (18:12 +0200)
src/editor.c
src/libgame/setup.c

index 5d38017e711084f4951f5270aaaa43ec995e6d6b..33f0d5b45388a07df884ebc7e2f419a05b680eb3 100644 (file)
@@ -7715,6 +7715,17 @@ static boolean PrepareSavingIntoPersonalLevelSet(void)
   leveldir_current =
     getTreeInfoFromIdentifier(leveldir_first, getLoginName());
 
+  // this may happen if "setup.internal.create_user_levelset" is FALSE
+  // or if file "levelinfo.conf" is missing in personal user level set
+  if (leveldir_current == NULL)
+  {
+    Request("Cannot find personal level set?!", REQ_CONFIRM);
+
+    leveldir_current = leveldir_former;
+
+    return FALSE;
+  }
+
   // find unused level number
   for (new_level_nr = leveldir_current->first_level; ; new_level_nr++)
   {
index 7f080d9c6c0f92fbdb4f2c2a860c7975f6a3ba54..db428ad5248b8afc6b029dbf27960efc79e7a388 100644 (file)
@@ -3889,6 +3889,11 @@ static boolean AddTreeSetToTreeInfoExt(TreeInfo *tree_node_old, char *tree_dir,
     {
       // get level info tree node of personal user level set
       tree_node_old = getTreeInfoFromIdentifier(leveldir_first, getLoginName());
+
+      // this may happen if "setup.internal.create_user_levelset" is FALSE
+      // or if file "levelinfo.conf" is missing in personal user level set
+      if (tree_node_old == NULL)
+       tree_node_old = leveldir_first->node_group;
     }
     else
     {