mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00:00
LibJS: Fix possible OOB read during Lexer construction
The Lexer constructor calls consume() once, which initializes m_position to be > 0 and sets m_character. consume() calls is_line_terminator(), which wasn't accounting for this state.
This commit is contained in:
committed by
Andreas Kling
parent
d477039abc
commit
922d0759b0
@@ -304,7 +304,7 @@ bool Lexer::is_line_terminator() const
|
||||
{
|
||||
if (m_current_char == '\n' || m_current_char == '\r')
|
||||
return true;
|
||||
if (m_position + 1 < m_source.length()) {
|
||||
if (m_position > 0 && m_position + 1 < m_source.length()) {
|
||||
auto three_chars_view = m_source.substring_view(m_position - 1, 3);
|
||||
return (three_chars_view == LINE_SEPARATOR) || (three_chars_view == PARAGRAPH_SEPARATOR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user