Skip to content

Commit 46bc0ff

Browse files
authored
src: do not read string out of bounds
PR-URL: #51358 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Keyhan Vakil <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent 3605574 commit 46bc0ff

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎src/path.cc‎

Lines changed: 5 additions & 6 deletions
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-
constauto 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-
} elseif (IsPathSeparator(path[i])){
31+
} elseif (IsPathSeparator(code)){
3332
break;
3433
} else{
35-
code = node::kPathSeparator;
34+
code = '/';
3635
}
3736

3837
if (IsPathSeparator(code)){

0 commit comments

Comments
(0)