From: Holger Schemel Date: Mon, 10 Feb 2020 22:21:35 +0000 (+0100) Subject: fixed potential crash bug if personal user level set cannot be found X-Git-Tag: 4.2.0.0~196 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=47d2e643b787f50db5ac9d8cceae6abe2b1600a6;p=rocksndiamonds.git fixed potential crash bug if personal user level set cannot be found --- diff --git a/src/editor.c b/src/editor.c index 5d38017e..33f0d5b4 100644 --- a/src/editor.c +++ b/src/editor.c @@ -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++) { diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 7f080d9c..db428ad5 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -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 {