75a61b
From 004e3c10df0abda214f0c293f9e269fdd979c5ee Mon Sep 17 00:00:00 2001
75a61b
From: Albert Astals Cid <aacid@kde.org>
75a61b
Date: Wed, 18 Jul 2018 20:31:27 +0200
75a61b
Subject: Fix crash when Object has negative number
75a61b
75a61b
Spec says object number has to be > 0 and gen has to be >= 0
75a61b
75a61b
Reported by email
75a61b
75a61b
Modified by Marek Kasik for older release
75a61b
75a61b
diff --git a/poppler/Parser.cc b/poppler/Parser.cc
75a61b
index 39c9a967..8b0093e3 100644
75a61b
--- a/poppler/Parser.cc
75a61b
+++ b/poppler/Parser.cc
75a61b
@@ -154,9 +154,14 @@ Object Parser::getObj(GBool simpleOnly,
75a61b
     num = buf1.getInt();
75a61b
     shift();
75a61b
     if (buf1.isInt() && buf2.isCmd("R")) {
75a61b
+      const int gen = buf1.getInt();
75a61b
-      obj->initRef(num, buf1.getInt());
75a61b
+      obj->initRef(num, gen);
75a61b
       shift();
75a61b
       shift();
75a61b
+
75a61b
+      if (unlikely(num <= 0 || gen < 0)) {
75a61b
+          obj->free();
75a61b
+      }
75a61b
     } else {
75a61b
       obj->initInt(num);
75a61b
     }