Merge pull request #7503 from edolstra/fix-dirOf

Fix CanonPath::dirOf() returning a string_view of a temporary
This commit is contained in:
Eelco Dolstra 2022-12-23 16:17:48 +01:00 committed by GitHub
commit 14f7dae3e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,7 +110,7 @@ public:
std::optional<std::string_view> dirOf() const
{
if (isRoot()) return std::nullopt;
return path.substr(0, path.rfind('/'));
return ((std::string_view) path).substr(0, path.rfind('/'));
}
std::optional<std::string_view> baseName() const