Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-11-01 05:42:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-11-01 05:43:35 +0300
commitb99d6e1bed5f238151abfc613448bbbfe67f78d0 (patch)
tree448ea2805065b87ac5bca30486e3c2abd3fabb0c /source/blender/blenkernel/intern/appdir.c
parente2937ff24fc833d64f1aa94b07079ad168e300ce (diff)
Fix errors in BKE_appdir_font_folder_default
- Missing NULL check for the HOME environment variable. - The user preference path was written to even when the path didn't exist.
Diffstat (limited to 'source/blender/blenkernel/intern/appdir.c')
-rw-r--r--source/blender/blenkernel/intern/appdir.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index a43b708db52..d872dc67dcb 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -281,22 +281,29 @@ bool BKE_appdir_folder_caches(char *r_path, const size_t path_len)
*/
bool BKE_appdir_font_folder_default(char *dir)
{
+ char test_dir[FILE_MAXDIR];
+ test_dir[0] = '\0';
+
#ifdef WIN32
wchar_t wpath[FILE_MAXDIR];
if (SHGetSpecialFolderPathW(0, wpath, CSIDL_FONTS, 0)) {
wcscat(wpath, L"\\");
- BLI_strncpy_wchar_as_utf8(dir, wpath, FILE_MAXDIR);
- return (BLI_exists(dir));
+ BLI_strncpy_wchar_as_utf8(test_dir, wpath, sizeof(test_dir));
}
- return false;
#elif defined(__APPLE__)
const char *home = BLI_getenv("HOME");
- BLI_snprintf(dir, FILE_MAXDIR, "%s/Library/Fonts/", home);
- return (BLI_exists(dir));
+ if (home) {
+ BLI_path_join(test_dir, sizeof(test_dir), home, "Library", "Fonts", NULL);
+ }
#else
- BLI_strncpy(dir, "/usr/share/fonts/", FILE_MAXDIR);
- return (BLI_exists(dir));
+ STRNCPY(test_dir, "/usr/share/fonts");
#endif
+
+ if (test_dir[0] && BLI_exists(test_dir)) {
+ BLI_strncpy(dir, test_dir, FILE_MAXDIR);
+ return true;
+ }
+ return false;
}
/** \} */