Skip to content

Commit d7df768

Browse files
authored
Merge pull request #7108 from bitjammer/rdar-28457876-fix-buffer-overflow
2 parents 7e4f876 + 92a9c4b commit d7df768

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Parse/Lexer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,11 @@ static bool isRightBound(const char *tokEnd, bool isLeftBound,
680680

681681
static bool rangeContainsPlaceholderEnd(const char *CurPtr,
682682
const char *End) {
683-
while (CurPtr++ < End - 1) {
684-
if (*CurPtr== '\n') {
683+
for (auto SubStr = CurPtr; SubStr != End - 1; ++SubStr) {
684+
if (SubStr[0] == '\n') {
685685
return false;
686686
}
687-
if (CurPtr[0] == '#' && CurPtr[1] == '>') {
687+
if (SubStr[0] == '#' && SubStr[1] == '>') {
688688
return true;
689689
}
690690
}
@@ -710,7 +710,7 @@ void Lexer::lexOperatorIdentifier() {
710710
// started with a '.'.
711711
if (*CurPtr == '.' && *TokStart != '.')
712712
break;
713-
if (Identifier::isEditorPlaceholder(StringRef(CurPtr, 2)) &&
713+
if (Identifier::isEditorPlaceholder(StringRef(CurPtr, BufferEnd-CurPtr)) &&
714714
rangeContainsPlaceholderEnd(CurPtr + 2, BufferEnd)) {
715715
break;
716716
}

0 commit comments

Comments
 (0)