[poppler] poppler/Stream.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 5 23:01:58 UTC 2021


 poppler/Stream.cc |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

New commits:
commit d0497325555d60c8c44f8945f5a99ab6a4d7c252
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Jan 5 23:55:46 2021 +0100

    Generalize the EOFStream wrapping EOFStream code

diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index cd1189d4..666d5b2a 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -167,6 +167,16 @@ GooString *Stream::getPSFilter(int psLevel, const char *indent)
     return new GooString();
 }
 
+static Stream *wrapEOFStream(Stream *str)
+{
+    if (dynamic_cast<EOFStream *>(str)) {
+        // str is already a EOFStream, no need to wrap it in another EOFStream
+        return str;
+    } else {
+        return new EOFStream(str);
+    }
+}
+
 Stream *Stream::addFilters(Dict *dict, int recursion)
 {
     Object obj, obj2;
@@ -196,11 +206,7 @@ Stream *Stream::addFilters(Dict *dict, int recursion)
                 str = makeFilter(obj2.getName(), str, &params2, recursion);
             } else {
                 error(errSyntaxError, getPos(), "Bad filter name");
-                if (dynamic_cast<EOFStream *>(str)) {
-                    // str is already a EOFStream, no need to wrap it in another EOFStream
-                } else {
-                    str = new EOFStream(str);
-                }
+                str = wrapEOFStream(str);
             }
         }
     } else if (!obj.isNull()) {
@@ -342,7 +348,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re
         str = new DCTStream(str, colorXform, dict, recursion);
 #else
         error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name);
-        str = new EOFStream(str);
+        str = wrapEOFStream(str);
 #endif
     } else if (!strcmp(name, "FlateDecode") || !strcmp(name, "Fl")) {
         pred = 1;
@@ -377,7 +383,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re
         str = new JPXStream(str);
 #else
         error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name);
-        str = new EOFStream(str);
+        str = wrapEOFStream(str);
 #endif
     } else if (!strcmp(name, "Crypt")) {
         if (str->getKind() == strCrypt) {
@@ -387,7 +393,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re
         }
     } else {
         error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name);
-        str = new EOFStream(str);
+        str = wrapEOFStream(str);
     }
     return str;
 }


More information about the poppler mailing list