[poppler] 2 commits - poppler/Stream.cc poppler/Stream.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Sep 14 17:58:16 UTC 2020


 poppler/Stream.cc |   22 +++++++++++++++++++++-
 poppler/Stream.h  |    3 ++-
 2 files changed, 23 insertions(+), 2 deletions(-)

New commits:
commit 12303bbdcc0cc72c6ff641140856f2c1f51041b8
Author: William Bader <william at newspapersystems.com>
Date:   Sun Sep 13 05:22:19 2020 +0100

    Improve EmbedStream::reset error checking.

diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 2b3eba85..2220f29c 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -1090,7 +1090,12 @@ void EmbedStream::reset()
         str->reset();
         // Might be a FilterStream that does not support str->setPos(start)
         while (str->getPos() < start) {
-            str->getChar();
+            if (str->getChar() == EOF) {
+                break;
+            }
+        }
+        if (str->getPos() != start) {
+            error(errInternal, -1, "Failed to reset EmbedStream");
         }
     }
     record = false;
commit e2ecddf3fc1f93a68b0ae535813f8b0d5ec672b5
Author: William Bader <william at newspapersystems.com>
Date:   Sun Sep 13 04:52:45 2020 +0100

    Implement EmbedStream::reset() to fix pdftops -level1sep -optimizecolorspace for in-line images.

diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 6eedfa00..2b3eba85 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -1069,6 +1069,7 @@ EmbedStream::EmbedStream(Stream *strA, Object &&dictA, bool limitedA, Goffset le
     reusable = reusableA;
     record = false;
     replay = false;
+    start = str->getPos();
     if (reusable) {
         bufData = (unsigned char *)gmalloc(16384);
         bufMax = 16384;
@@ -1083,13 +1084,27 @@ EmbedStream::~EmbedStream()
         gfree(bufData);
 }
 
+void EmbedStream::reset()
+{
+    if (str->getPos() != start) {
+        str->reset();
+        // Might be a FilterStream that does not support str->setPos(start)
+        while (str->getPos() < start) {
+            str->getChar();
+        }
+    }
+    record = false;
+    replay = false;
+    bufPos = 0;
+}
+
 BaseStream *EmbedStream::copy()
 {
     error(errInternal, -1, "Called copy() on EmbedStream");
     return nullptr;
 }
 
-Stream *EmbedStream::makeSubStream(Goffset start, bool limitedA, Goffset lengthA, Object &&dictA)
+Stream *EmbedStream::makeSubStream(Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA)
 {
     error(errInternal, -1, "Called makeSubStream() on EmbedStream");
     return nullptr;
diff --git a/poppler/Stream.h b/poppler/Stream.h
index 5d9ad0c9..abd60d4b 100644
--- a/poppler/Stream.h
+++ b/poppler/Stream.h
@@ -747,7 +747,7 @@ public:
     BaseStream *copy() override;
     Stream *makeSubStream(Goffset start, bool limitedA, Goffset lengthA, Object &&dictA) override;
     StreamKind getKind() const override { return str->getKind(); }
-    void reset() override { }
+    void reset() override;
     int getChar() override;
     int lookChar() override;
     Goffset getPos() override;
@@ -774,6 +774,7 @@ private:
     long bufMax;
     long bufLen;
     long bufPos;
+    Goffset start;
 };
 
 //------------------------------------------------------------------------


More information about the poppler mailing list