Use UnownedPtr<> in JBIG2_SDDProc.

Pack a little tighter while at it.

Change-Id: If7cbb324ebf828a4bb60eb364fc3e0f31625e57f
Reviewed-on: https://pdfium-review.googlesource.com/40913
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 29c604f..7bdcf5c 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -22,6 +22,10 @@
 #include "core/fxcodec/jbig2/JBig2_TrdProc.h"
 #include "third_party/base/ptr_util.h"
 
+CJBig2_SDDProc::CJBig2_SDDProc() = default;
+
+CJBig2_SDDProc::~CJBig2_SDDProc() = default;
+
 std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::DecodeArith(
     CJBig2_ArithDecoder* pArithDecoder,
     std::vector<JBig2ArithCtx>* gbContext,
@@ -289,7 +293,7 @@
   NSYMSDECODED = 0;
   std::unique_ptr<CJBig2_Image> BS;
   while (NSYMSDECODED < SDNUMNEWSYMS) {
-    if (pHuffmanDecoder->DecodeAValue(SDHUFFDH, &HCDH) != 0)
+    if (pHuffmanDecoder->DecodeAValue(SDHUFFDH.Get(), &HCDH) != 0)
       return nullptr;
 
     HCHEIGHT = HCHEIGHT + HCDH;
@@ -300,7 +304,7 @@
     TOTWIDTH = 0;
     HCFIRSTSYM = NSYMSDECODED;
     for (;;) {
-      nVal = pHuffmanDecoder->DecodeAValue(SDHUFFDW, &DW);
+      nVal = pHuffmanDecoder->DecodeAValue(SDHUFFDW.Get(), &DW);
       if (nVal == JBIG2_OOB)
         break;
       if (nVal != 0)
@@ -319,8 +323,8 @@
       }
       TOTWIDTH = TOTWIDTH + SYMWIDTH;
       if (SDREFAGG == 1) {
-        if (pHuffmanDecoder->DecodeAValue(SDHUFFAGGINST, (int*)&REFAGGNINST) !=
-            0) {
+        if (pHuffmanDecoder->DecodeAValue(SDHUFFAGGINST.Get(),
+                                          (int*)&REFAGGNINST) != 0) {
           return nullptr;
         }
         BS = nullptr;
@@ -440,9 +444,10 @@
       NSYMSDECODED = NSYMSDECODED + 1;
     }
     if (SDREFAGG == 0) {
-      if (pHuffmanDecoder->DecodeAValue(SDHUFFBMSIZE, (int32_t*)&BMSIZE) != 0)
+      if (pHuffmanDecoder->DecodeAValue(SDHUFFBMSIZE.Get(),
+                                        (int32_t*)&BMSIZE) != 0) {
         return nullptr;
-
+      }
       pStream->alignByte();
       std::unique_ptr<CJBig2_Image> BHC;
       if (BMSIZE == 0) {
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.h b/core/fxcodec/jbig2/JBig2_SddProc.h
index a6fb039..abef010 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.h
+++ b/core/fxcodec/jbig2/JBig2_SddProc.h
@@ -12,6 +12,7 @@
 
 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h"
 #include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/unowned_ptr.h"
 
 class CJBig2_BitStream;
 class CJBig2_HuffmanTable;
@@ -20,6 +21,9 @@
 
 class CJBig2_SDDProc {
  public:
+  CJBig2_SDDProc();
+  ~CJBig2_SDDProc();
+
   std::unique_ptr<CJBig2_SymbolDict> DecodeArith(
       CJBig2_ArithDecoder* pArithDecoder,
       std::vector<JBig2ArithCtx>* gbContext,
@@ -32,17 +36,17 @@
 
   bool SDHUFF;
   bool SDREFAGG;
+  bool SDRTEMPLATE;
+  uint8_t SDTEMPLATE;
   uint32_t SDNUMINSYMS;
-  CJBig2_Image** SDINSYMS;
   uint32_t SDNUMNEWSYMS;
   uint32_t SDNUMEXSYMS;
-  const CJBig2_HuffmanTable* SDHUFFDH;
-  const CJBig2_HuffmanTable* SDHUFFDW;
-  const CJBig2_HuffmanTable* SDHUFFBMSIZE;
-  const CJBig2_HuffmanTable* SDHUFFAGGINST;
-  uint8_t SDTEMPLATE;
+  CJBig2_Image** SDINSYMS;
+  UnownedPtr<const CJBig2_HuffmanTable> SDHUFFDH;
+  UnownedPtr<const CJBig2_HuffmanTable> SDHUFFDW;
+  UnownedPtr<const CJBig2_HuffmanTable> SDHUFFBMSIZE;
+  UnownedPtr<const CJBig2_HuffmanTable> SDHUFFAGGINST;
   int8_t SDAT[8];
-  bool SDRTEMPLATE;
   int8_t SDRAT[4];
 };