mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-07 14:12:09 +00:00
Lex: Don't crash if both conflict markers are on the same line
We would check if the terminator marker is on a newline. However, the logic would end up out-of-bounds if the terminator marker immediately follows the start marker. This fixes PR21820. llvm-svn: 224210
This commit is contained in:
parent
11c4874d83
commit
5a54977ea8
@ -2588,8 +2588,8 @@ static const char *FindConflictEnd(const char *CurPtr, const char *BufferEnd,
|
||||
size_t Pos = RestOfBuffer.find(Terminator);
|
||||
while (Pos != StringRef::npos) {
|
||||
// Must occur at start of line.
|
||||
if (RestOfBuffer[Pos-1] != '\r' &&
|
||||
RestOfBuffer[Pos-1] != '\n') {
|
||||
if (Pos == 0 ||
|
||||
(RestOfBuffer[Pos - 1] != '\r' && RestOfBuffer[Pos - 1] != '\n')) {
|
||||
RestOfBuffer = RestOfBuffer.substr(Pos+TermLen);
|
||||
Pos = RestOfBuffer.find(Terminator);
|
||||
continue;
|
||||
|
@ -36,3 +36,5 @@ int foo() {
|
||||
y a = x;
|
||||
return x + a - z;
|
||||
}
|
||||
|
||||
<<<<<<<>>>>>>> // expected-error {{expected identifier}}
|
||||
|
Loading…
Reference in New Issue
Block a user