From 79bce99260ccfbe987add42fba9a5b32214c261d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 27 Feb 2023 14:02:03 +0100 Subject: [PATCH] Fix #104857: crash when datafiles/assets folder does not exist This adds some simple null checks to avoid the crash. It might still be good to improve the error message, but also does not seem as important as avoiding the crash. Typically, users should not run into this issue because the assets are shipped with Blender. --- source/blender/asset_system/intern/asset_essentials_library.cc | 3 +++ source/blender/asset_system/intern/asset_library_service.cc | 3 +++ 2 files changed, 6 insertions(+) diff --git a/source/blender/asset_system/intern/asset_essentials_library.cc b/source/blender/asset_system/intern/asset_essentials_library.cc index 8a4e51af27a..70b15394df2 100644 --- a/source/blender/asset_system/intern/asset_essentials_library.cc +++ b/source/blender/asset_system/intern/asset_essentials_library.cc @@ -16,6 +16,9 @@ StringRefNull essentials_directory_path() { static std::string path = []() { const char *datafiles_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "assets"); + if (datafiles_path == nullptr) { + return ""; + } return datafiles_path; }(); return path; diff --git a/source/blender/asset_system/intern/asset_library_service.cc b/source/blender/asset_system/intern/asset_library_service.cc index bdffbc17a16..1ce1fdd0dc8 100644 --- a/source/blender/asset_system/intern/asset_library_service.cc +++ b/source/blender/asset_system/intern/asset_library_service.cc @@ -63,6 +63,9 @@ AssetLibrary *AssetLibraryService::get_asset_library( switch (type) { case ASSET_LIBRARY_ESSENTIALS: { const StringRefNull root_path = essentials_directory_path(); + if (root_path.is_empty()) { + return nullptr; + } AssetLibrary *library = get_asset_library_on_disk(root_path); library->import_method_ = ASSET_IMPORT_APPEND_REUSE;