From ff9d9711d71a7bbef24ba1b403f49c4b140bd408 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 Oct 2024 13:00:52 +1100 Subject: [PATCH] Fix crash using "~" in the file selector when the "home" is null --- source/blender/editors/space_file/file_ops.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_file/file_ops.cc b/source/blender/editors/space_file/file_ops.cc index ab6213624b9..ae874408934 100644 --- a/source/blender/editors/space_file/file_ops.cc +++ b/source/blender/editors/space_file/file_ops.cc @@ -2764,12 +2764,18 @@ static void file_expand_directory(bContext *C) /* While path handling expansion typically doesn't support home directory expansion * in Blender, this is a convenience to be able to type in a single character. * Even though this is a UNIX convention, it's harmless to expand on WIN32 as well. */ - char tmpstr[sizeof(params->dir) - 1]; - STRNCPY(tmpstr, params->dir + 1); - BLI_path_join(params->dir, sizeof(params->dir), BKE_appdir_folder_home(), tmpstr); + if (const char *home_dir = BKE_appdir_folder_home()) { + char tmpstr[sizeof(params->dir) - 1]; + STRNCPY(tmpstr, params->dir + 1); + BLI_path_join(params->dir, sizeof(params->dir), home_dir, tmpstr); + } + else { + /* Fall back to the default root. */ + params->dir[0] = '\0'; + } } - else if (params->dir[0] == '\0') + if (params->dir[0] == '\0') #ifndef WIN32 { params->dir[0] = '/';