3dc527
--- poppler-0.26.5/poppler/Parser.cc
3dc527
+++ poppler-0.26.5/poppler/Parser.cc
3dc527
@@ -19,6 +19,7 @@
3dc527
 // Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
3dc527
 // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
3dc527
 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
3dc527
+// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
3dc527
 //
3dc527
 // To see a description of the changes please see the Changelog file that
3dc527
 // came with your tarball or type make ChangeLog if you are building from git
3dc527
@@ -257,6 +258,12 @@ Stream *Parser::makeStream(Object *dict,
3dc527
       pos = pos - 1;
3dc527
       lexer->lookCharLastValueCached = Lexer::LOOK_VALUE_NOT_CACHED;
3dc527
   }
3dc527
+  if (unlikely(length < 0)) {
3dc527
+      return NULL;
3dc527
+  }
3dc527
+  if (unlikely(pos > LONG_LONG_MAX - length)) {
3dc527
+      return NULL;
3dc527
+  }
3dc527
   lexer->setPos(pos + length);
3dc527
 
3dc527
   // refill token buffers and check for 'endstream'