mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +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
Notes:
sideshowbarker
2024-07-18 01:05:44 +09:00
Author: https://github.com/swoertz Commit: https://github.com/SerenityOS/serenity/commit/b87ab989a3f Pull-request: https://github.com/SerenityOS/serenity/pull/10923 Issue: https://github.com/SerenityOS/serenity/issues/10717
1 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue