Merge pull request #9934 from nmeum/absPath-out-of-bounds

absPath: Explicitly check if path is empty before accessing it
This commit is contained in:
Eelco Dolstra 2024-02-05 14:44:02 +01:00 committed by GitHub
commit 6ec08b85f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -25,7 +25,7 @@ Path absPath(PathView path, std::optional<PathView> dir, bool resolveSymlinks)
{
std::string scratch;
if (path[0] != '/') {
if (path.empty() || path[0] != '/') {
// In this case we need to call `canonPath` on a newly-created
// string. We set `scratch` to that string first, and then set
// `path` to `scratch`. This ensures the newly-created string