Преглед на файлове

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.
Simon Woertz преди 3 години
родител
ревизия
b87ab989a3
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      Userland/Libraries/LibPDF/Parser.cpp

+ 3 - 1
Userland/Libraries/LibPDF/Parser.cpp

@@ -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;
 }
 }