From 9edbef8bf5685041cbc834fbf0b9fc702ffa01eb Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 23 Sep 2024 10:20:27 +0900 Subject: [PATCH] src: do not call path.back() when it is empty --- src/path.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/path.cc b/src/path.cc index f1813596ff78ff..df6a11644b4c1a 100644 --- a/src/path.cc +++ b/src/path.cc @@ -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(i) == numArgs - 1 && path.back() == '/') { - slashCheck = true; - } - if (!path.empty()) { + if (static_cast(i) == numArgs - 1 && path.back() == '/') { + slashCheck = true; + } + resolvedPath = std::string(path) + "/" + resolvedPath; if (path.front() == '/') {