Skip to content

Commit

Permalink
src: do not call path.back() when it is empty
Browse files Browse the repository at this point in the history
PR-URL: #55072
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
zcbenz authored Sep 25, 2024
1 parent 0e52836 commit 773e7c6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ std::string PathResolve(Environment* env,
for (int i = numArgs - 1; i >= -1 && !resolvedAbsolute; i--) {
const std::string& path = (i >= 0) ? std::string(paths[i]) : cwd;

if (static_cast<size_t>(i) == numArgs - 1 && path.back() == '/') {
slashCheck = true;
}

if (!path.empty()) {
if (static_cast<size_t>(i) == numArgs - 1 && path.back() == '/') {
slashCheck = true;
}

resolvedPath = std::string(path) + "/" + resolvedPath;

if (path.front() == '/') {
Expand Down

0 comments on commit 773e7c6

Please sign in to comment.