Skip to content

Commit 7bc8675

Browse files
committed
src: do not read string out of bounds
1 parent d449e34 commit 7bc8675

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/path.cc

+5-6
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ std::string NormalizeString(const std::string_view path,
2424
int lastSegmentLength = 0;
2525
int lastSlash = -1;
2626
int dots = 0;
27-
char code;
28-
const auto pathLen = path.size();
29-
for (uint8_t i = 0; i <= pathLen; ++i) {
30-
if (i < pathLen) {
27+
char code = 0;
28+
for (size_t i = 0; i <= path.size(); ++i) {
29+
if (i < path.size()) {
3130
code = path[i];
32-
} else if (IsPathSeparator(path[i])) {
31+
} else if (IsPathSeparator(code)) {
3332
break;
3433
} else {
35-
code = node::kPathSeparator;
34+
code = '/';
3635
}
3736

3837
if (IsPathSeparator(code)) {

0 commit comments

Comments
 (0)