mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
LibLine: Reset state after invalid character in DSR response
While parsing DSR response, we might encounter invalid characters, for example, when we `cat` a binary file. Previously, we just pushed those characters in `m_incomplete_data` buffer, which worked fine until we didn't get a terminating character. We kept increasing coordinate value and crashed in following assertion.
This commit is contained in:
parent
7b3559f1c2
commit
1f0149e5a6
1 changed files with 6 additions and 0 deletions
|
@ -2128,14 +2128,17 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_incomplete_data.append(c);
|
m_incomplete_data.append(c);
|
||||||
|
state = Free;
|
||||||
continue;
|
continue;
|
||||||
case SawBracket:
|
case SawBracket:
|
||||||
if (is_ascii_digit(c)) {
|
if (is_ascii_digit(c)) {
|
||||||
state = InFirstCoordinate;
|
state = InFirstCoordinate;
|
||||||
|
coordinate_buffer.clear_with_capacity();
|
||||||
coordinate_buffer.append(c);
|
coordinate_buffer.append(c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_incomplete_data.append(c);
|
m_incomplete_data.append(c);
|
||||||
|
state = Free;
|
||||||
continue;
|
continue;
|
||||||
case InFirstCoordinate:
|
case InFirstCoordinate:
|
||||||
if (is_ascii_digit(c)) {
|
if (is_ascii_digit(c)) {
|
||||||
|
@ -2152,6 +2155,7 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_incomplete_data.append(c);
|
m_incomplete_data.append(c);
|
||||||
|
state = Free;
|
||||||
continue;
|
continue;
|
||||||
case SawSemicolon:
|
case SawSemicolon:
|
||||||
if (is_ascii_digit(c)) {
|
if (is_ascii_digit(c)) {
|
||||||
|
@ -2160,6 +2164,7 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_incomplete_data.append(c);
|
m_incomplete_data.append(c);
|
||||||
|
state = Free;
|
||||||
continue;
|
continue;
|
||||||
case InSecondCoordinate:
|
case InSecondCoordinate:
|
||||||
if (is_ascii_digit(c)) {
|
if (is_ascii_digit(c)) {
|
||||||
|
@ -2176,6 +2181,7 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_incomplete_data.append(c);
|
m_incomplete_data.append(c);
|
||||||
|
state = Free;
|
||||||
continue;
|
continue;
|
||||||
case SawR:
|
case SawR:
|
||||||
m_incomplete_data.append(c);
|
m_incomplete_data.append(c);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue