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:
Simon Woertz 2021-11-14 20:11:33 +01:00 committed by Andreas Kling
parent f1d8978804
commit b87ab989a3
Notes: sideshowbarker 2024-07-18 01:05:44 +09:00

View file

@ -1144,11 +1144,13 @@ bool Parser::matches_regular_character() const
bool Parser::consume_eol()
{
if (m_reader.done()) {
return false;
}
if (m_reader.matches("\r\n")) {
consume(2);
return true;
}
auto consumed = consume();
return consumed == 0xd || consumed == 0xa;
}