From b87ab989a3f11adc5aa95a6e69e5c8185680bf57 Mon Sep 17 00:00:00 2001 From: Simon Woertz Date: Sun, 14 Nov 2021 20:11:33 +0100 Subject: 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. --- Userland/Libraries/LibPDF/Parser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries') 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; } -- cgit v1.2.3