mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
LibPDF: Check if there is data left before consuming
Add a check to `Parser::consume_eol` to ensure that there is more data to read before actually consuming any data. Not checking if there is data left leads to failing an assertion in case of e.g., a truncated pdf file.
This commit is contained in:
parent
f1d8978804
commit
b87ab989a3
1 changed files with 3 additions and 1 deletions
|
@ -1144,11 +1144,13 @@ bool Parser::matches_regular_character() const
|
||||||
|
|
||||||
bool Parser::consume_eol()
|
bool Parser::consume_eol()
|
||||||
{
|
{
|
||||||
|
if (m_reader.done()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (m_reader.matches("\r\n")) {
|
if (m_reader.matches("\r\n")) {
|
||||||
consume(2);
|
consume(2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto consumed = consume();
|
auto consumed = consume();
|
||||||
return consumed == 0xd || consumed == 0xa;
|
return consumed == 0xd || consumed == 0xa;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue