From e3c988aa8b6e6f348a4394e81cc72b3a1fc9204e Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Tue, 4 Mar 2025 19:36:42 +0000 Subject: [PATCH] FileSystem: Improve handling of relative paths in RealPath() --- common/FileSystem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/FileSystem.cpp b/common/FileSystem.cpp index 888b985ff9..86e0e151ec 100644 --- a/common/FileSystem.cpp +++ b/common/FileSystem.cpp @@ -288,8 +288,14 @@ std::string Path::RealPath(const std::string_view path) { // Resolve non-absolute paths first. std::vector components; + // We need to keep the full combined path in scope + // as SplitNativePath() returns string_views to it. + std::string buf; if (!IsAbsolute(path)) - components = Path::SplitNativePath(Path::Combine(FileSystem::GetWorkingDirectory(), path)); + { + buf = Path::Combine(FileSystem::GetWorkingDirectory(), path); + components = Path::SplitNativePath(buf); + } else components = Path::SplitNativePath(path);