From efdda781755ade5c079a081dba582feabcf2bf97 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 21 May 2025 20:35:24 +0200 Subject: [PATCH] Fix #136906: Crash if asset library path contains back slash on macOS Convert all slashes to native format when initializing an asset library. This might convert slashes that are valid parts of the file name, but this just leads to an error about a not found asset library, which is better than crashing. This is a typical tradeoff when dealing with cross platform paths. --- source/blender/asset_system/intern/utils.cc | 1 + source/blender/asset_system/intern/utils.hh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/asset_system/intern/utils.cc b/source/blender/asset_system/intern/utils.cc index 8383395f934..7e50ef48d11 100644 --- a/source/blender/asset_system/intern/utils.cc +++ b/source/blender/asset_system/intern/utils.cc @@ -25,6 +25,7 @@ std::string normalize_directory_path(StringRef directory) directory.data(), /* + 1 for null terminator. */ std::min(directory.size() + 1, int64_t(sizeof(dir_normalized)))); + BLI_path_slash_native(dir_normalized); BLI_path_normalize_dir(dir_normalized, sizeof(dir_normalized)); return std::string(dir_normalized); } diff --git a/source/blender/asset_system/intern/utils.hh b/source/blender/asset_system/intern/utils.hh index a04600e0522..f1b6f30b911 100644 --- a/source/blender/asset_system/intern/utils.hh +++ b/source/blender/asset_system/intern/utils.hh @@ -14,7 +14,7 @@ namespace blender::asset_system::utils { /** * Returns a normalized directory path with a trailing slash, and a maximum length of #PATH_MAX. - * Slashes are not converted to native format (they probably should be though?). + * Slashes are converted to native format. */ std::string normalize_directory_path(StringRef directory);