summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSimon Woertz <simon@woertz.at>2021-11-14 20:11:33 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-16 00:16:57 +0100
commitb87ab989a3f11adc5aa95a6e69e5c8185680bf57 (patch)
tree75f7b555ded5541628d167b46554ab93044ef878 /Userland/Libraries
parentf1d8978804900311d348da1651d7e17ad218b80f (diff)
downloadserenity-b87ab989a3f11adc5aa95a6e69e5c8185680bf57.zip
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibPDF/Parser.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibPDF/Parser.cpp b/Userland/Libraries/LibPDF/Parser.cpp
index 7565f6cd18..105b5d7f3b 100644
--- a/Userland/Libraries/LibPDF/Parser.cpp
+++ b/Userland/Libraries/LibPDF/Parser.cpp
@@ -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;
}