From 68ef84e5968a4249c2162b839ca6d7975048a557 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Mon, 15 Jul 2019 23:24:22 +0200
Subject: [PATCH] JPXStream::init: ignore dict Length if clearly broken

Fixes issue #805
---
 poppler/JPEG2000Stream.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -Nurp poppler-0.67.0/poppler/JPEG2000Stream.cc poppler-0.67.0-bak/poppler/JPEG2000Stream.cc
--- poppler-0.67.0/poppler/JPEG2000Stream.cc	2018-07-19 17:20:03.000000000 -0400
+++ poppler-0.67.0-bak/poppler/JPEG2000Stream.cc	2019-08-15 14:10:20.618000000 -0400
@@ -219,7 +219,7 @@ void JPXStream::init()
   }
 
   int bufSize = BUFFER_INITIAL_SIZE;
-  if (oLen.isInt()) bufSize = oLen.getInt();
+  if (oLen.isInt() && oLen.getInt() > 0) bufSize = oLen.getInt();
 
   GBool indexed = gFalse;
   if (cspace.isArray() && cspace.arrayGetLength() > 0) {
