Skip to content

Commit 773e7c6

Browse files
authored
src: do not call path.back() when it is empty
PR-URL: #55072 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 0e52836 commit 773e7c6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/path.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ std::string PathResolve(Environment* env,
266266
for (int i = numArgs - 1; i >= -1 && !resolvedAbsolute; i--) {
267267
const std::string& path = (i >= 0) ? std::string(paths[i]) : cwd;
268268

269-
if (static_cast<size_t>(i) == numArgs - 1 && path.back() == '/') {
270-
slashCheck = true;
271-
}
272-
273269
if (!path.empty()) {
270+
if (static_cast<size_t>(i) == numArgs - 1 && path.back() == '/') {
271+
slashCheck = true;
272+
}
273+
274274
resolvedPath = std::string(path) + "/" + resolvedPath;
275275

276276
if (path.front() == '/') {

0 commit comments

Comments
 (0)