[poppler] poppler/JBIG2Stream.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 5 19:04:20 UTC 2021


 poppler/JBIG2Stream.cc |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

New commits:
commit f2a6c6fe06ba2279f8509c56a11d649f02d1500c
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Jul 4 22:02:08 2021 +0200

    JBIG2Stream: Fix regression caused by 2b2808719d2c91283ae358381391bb0b37d9061d

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 6ee19847..725b2cf9 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -967,13 +967,14 @@ public:
     unsigned int getSize() { return size; }
     void setBitmap(unsigned int idx, JBIG2Bitmap *bitmap) { bitmaps[idx] = bitmap; }
     JBIG2Bitmap *getBitmap(unsigned int idx) { return bitmaps[idx]; }
-    bool isOk() { return bitmaps != nullptr || size == 0; }
+    bool isOk() const { return ok; }
     void setGenericRegionStats(JArithmeticDecoderStats *stats) { genericRegionStats = stats; }
     void setRefinementRegionStats(JArithmeticDecoderStats *stats) { refinementRegionStats = stats; }
     JArithmeticDecoderStats *getGenericRegionStats() { return genericRegionStats; }
     JArithmeticDecoderStats *getRefinementRegionStats() { return refinementRegionStats; }
 
 private:
+    bool ok;
     unsigned int size;
     JBIG2Bitmap **bitmaps;
     JArithmeticDecoderStats *genericRegionStats;
@@ -982,13 +983,18 @@ private:
 
 JBIG2SymbolDict::JBIG2SymbolDict(unsigned int segNumA, unsigned int sizeA) : JBIG2Segment(segNumA)
 {
-    unsigned int i;
-
+    ok = true;
     size = sizeA;
-    bitmaps = (JBIG2Bitmap **)gmallocn_checkoverflow(size, sizeof(JBIG2Bitmap *));
-    if (!bitmaps)
-        size = 0;
-    for (i = 0; i < size; ++i) {
+    if (size != 0) {
+        bitmaps = (JBIG2Bitmap **)gmallocn_checkoverflow(size, sizeof(JBIG2Bitmap *));
+        if (!bitmaps) {
+            ok = false;
+            size = 0;
+        }
+    } else {
+        bitmaps = nullptr;
+    }
+    for (unsigned int i = 0; i < size; ++i) {
         bitmaps[i] = nullptr;
     }
     genericRegionStats = nullptr;


More information about the poppler mailing list