summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_SddProc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_SddProc.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_SddProc.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 7bdcf5c5f9..0d2ce14de2 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -120,6 +120,15 @@ std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::DecodeArith(
} else {
IAAI->Decode(pArithDecoder, (int*)&REFAGGNINST);
if (REFAGGNINST > 1) {
+ // Huffman tables must not outlive |pDecoder|.
+ auto SBHUFFFS = pdfium::MakeUnique<CJBig2_HuffmanTable>(6);
+ auto SBHUFFDS = pdfium::MakeUnique<CJBig2_HuffmanTable>(8);
+ auto SBHUFFDT = pdfium::MakeUnique<CJBig2_HuffmanTable>(11);
+ auto SBHUFFRDW = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRDH = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRDX = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRDY = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRSIZE = pdfium::MakeUnique<CJBig2_HuffmanTable>(1);
auto pDecoder = pdfium::MakeUnique<CJBig2_TRDProc>();
pDecoder->SBHUFF = SDHUFF;
pDecoder->SBREFINE = 1;
@@ -145,14 +154,6 @@ std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::DecodeArith(
pDecoder->TRANSPOSED = 0;
pDecoder->REFCORNER = JBIG2_CORNER_TOPLEFT;
pDecoder->SBDSOFFSET = 0;
- auto SBHUFFFS = pdfium::MakeUnique<CJBig2_HuffmanTable>(6);
- auto SBHUFFDS = pdfium::MakeUnique<CJBig2_HuffmanTable>(8);
- auto SBHUFFDT = pdfium::MakeUnique<CJBig2_HuffmanTable>(11);
- auto SBHUFFRDW = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRDH = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRDX = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRDY = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRSIZE = pdfium::MakeUnique<CJBig2_HuffmanTable>(1);
pDecoder->SBHUFFFS = SBHUFFFS.get();
pDecoder->SBHUFFDS = SBHUFFDS.get();
pDecoder->SBHUFFDT = SBHUFFDT.get();
@@ -329,6 +330,15 @@ std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::DecodeHuffman(
}
BS = nullptr;
if (REFAGGNINST > 1) {
+ // Huffman tables must outlive |pDecoder|.
+ auto SBHUFFFS = pdfium::MakeUnique<CJBig2_HuffmanTable>(6);
+ auto SBHUFFDS = pdfium::MakeUnique<CJBig2_HuffmanTable>(8);
+ auto SBHUFFDT = pdfium::MakeUnique<CJBig2_HuffmanTable>(11);
+ auto SBHUFFRDW = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRDH = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRDX = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRDY = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
+ auto SBHUFFRSIZE = pdfium::MakeUnique<CJBig2_HuffmanTable>(1);
auto pDecoder = pdfium::MakeUnique<CJBig2_TRDProc>();
pDecoder->SBHUFF = SDHUFF;
pDecoder->SBREFINE = 1;
@@ -357,14 +367,6 @@ std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::DecodeHuffman(
pDecoder->TRANSPOSED = 0;
pDecoder->REFCORNER = JBIG2_CORNER_TOPLEFT;
pDecoder->SBDSOFFSET = 0;
- auto SBHUFFFS = pdfium::MakeUnique<CJBig2_HuffmanTable>(6);
- auto SBHUFFDS = pdfium::MakeUnique<CJBig2_HuffmanTable>(8);
- auto SBHUFFDT = pdfium::MakeUnique<CJBig2_HuffmanTable>(11);
- auto SBHUFFRDW = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRDH = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRDX = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRDY = pdfium::MakeUnique<CJBig2_HuffmanTable>(15);
- auto SBHUFFRSIZE = pdfium::MakeUnique<CJBig2_HuffmanTable>(1);
pDecoder->SBHUFFFS = SBHUFFFS.get();
pDecoder->SBHUFFDS = SBHUFFDS.get();
pDecoder->SBHUFFDT = SBHUFFDT.get();