diff options
author | Albert Astals Cid <aacid@kde.org> | 2021-07-04 22:02:08 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2021-07-05 20:59:06 +0200 |
commit | f2a6c6fe06ba2279f8509c56a11d649f02d1500c (patch) | |
tree | 196eddac60b29e2e86c4f2bcf426f67792e22fcb | |
parent | fcdff7bb19e2ac0fab6505f17e0c18c8faa86323 (diff) |
JBIG2Stream: Fix regression caused by 2b2808719d2c91283ae358381391bb0b37d9061d
-rw-r--r-- | poppler/JBIG2Stream.cc | 20 |
1 files changed, 13 insertions, 7 deletions
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; |