Fix crash when "HOME" environment variable isn't defined

Accessing the default directory in the file selector
would crash if HOME was undefined.

Add BKE_appdir_folder_default_or_root which never returns NULL.
This commit is contained in:
2021-11-01 13:09:02 +11:00
parent d4d38e8a34
commit a0633e2484
6 changed files with 41 additions and 14 deletions

View File

@@ -2463,12 +2463,14 @@ static void file_expand_directory(bContext *C)
if (BLI_path_is_rel(params->dir)) {
/* Use of 'default' folder here is just to avoid an error message on '//' prefix. */
BLI_path_abs(params->dir,
G.relbase_valid ? BKE_main_blendfile_path(bmain) : BKE_appdir_folder_default());
G.relbase_valid ? BKE_main_blendfile_path(bmain) :
BKE_appdir_folder_default_or_root());
}
else if (params->dir[0] == '~') {
char tmpstr[sizeof(params->dir) - 1];
BLI_strncpy(tmpstr, params->dir + 1, sizeof(tmpstr));
BLI_join_dirfile(params->dir, sizeof(params->dir), BKE_appdir_folder_default(), tmpstr);
BLI_path_join(
params->dir, sizeof(params->dir), BKE_appdir_folder_default_or_root(), tmpstr, NULL);
}
else if (params->dir[0] == '\0')