Skip to content

Commit 17a530e

Browse files
committed
More robust comment checking
1 parent 6e3b017 commit 17a530e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/attributes.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,8 +2357,12 @@ namespace attributes {
23572357
// returns std::string::npos if no match is found
23582358
size_t findComment(std::string const& str, size_t idx) {
23592359
size_t firstSlash = str.find("/", idx);
2360-
if (str[firstSlash + 1] == '/') return firstSlash;
2361-
else return std::string::npos;
2360+
if (firstSlash != std::string::npos) {
2361+
if (firstSlash + 1 < str.length() && str[firstSlash + 1] == '/') {
2362+
return firstSlash;
2363+
}
2364+
}
2365+
return std::string::npos;
23622366
}
23632367

23642368
// Remove trailing line comments -- ie, find comments that don't begin

0 commit comments

Comments
 (0)