Skip to content

Commit

Permalink
src: do not read string out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Jan 4, 2024
1 parent 084d761 commit c778390
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@ std::string NormalizeString(const std::string_view path,
int lastSegmentLength = 0;
int lastSlash = -1;
int dots = 0;
char code;
const auto pathLen = path.size();
for (uint8_t i = 0; i <= pathLen; ++i) {
if (i < pathLen) {
code = path[i];
} else if (IsPathSeparator(path[i])) {
break;
} else {
code = node::kPathSeparator;
}
for (size_t i = 0; i < path.size(); ++i) {
char code = path[i];

if (IsPathSeparator(code)) {
if (lastSlash == static_cast<int>(i - 1) || dots == 1) {
Expand Down

0 comments on commit c778390

Please sign in to comment.