Initialize CFX_LZWDecompressor members in the header.

Along the way:
- Mark more members const.
- Initialize one member that wasn't initialized before.
- Use pdfium::WrapUnique() in Create().

Change-Id: I6998bfe72b14f94528e20050028b2753768fde74
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/70920
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.cpp b/core/fxcodec/gif/cfx_lzwdecompressor.cpp
index 35697fe..ccf5c12 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor.cpp
+++ b/core/fxcodec/gif/cfx_lzwdecompressor.cpp
@@ -13,31 +13,25 @@
 
 #include "core/fxcrt/fx_safe_types.h"
 #include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
 
 std::unique_ptr<CFX_LZWDecompressor> CFX_LZWDecompressor::Create(
     uint8_t color_exp,
     uint8_t code_exp) {
-  // color_exp generates 2^(n + 1) codes, where as the code_exp reserves 2^n.
+  // |color_exp| generates 2^(n + 1) codes, where as the code_exp reserves 2^n.
   // This is a quirk of the GIF spec.
   if (code_exp > GIF_MAX_LZW_EXP || code_exp < color_exp + 1)
     return nullptr;
-  return std::unique_ptr<CFX_LZWDecompressor>(
-      new CFX_LZWDecompressor(color_exp, code_exp));
+
+  // Private ctor.
+  return pdfium::WrapUnique(new CFX_LZWDecompressor(color_exp, code_exp));
 }
 
 CFX_LZWDecompressor::CFX_LZWDecompressor(uint8_t color_exp, uint8_t code_exp)
     : code_size_(code_exp),
-      code_size_cur_(0),
       code_color_end_(static_cast<uint16_t>(1 << (color_exp + 1))),
       code_clear_(static_cast<uint16_t>(1 << code_exp)),
-      code_end_(static_cast<uint16_t>((1 << code_exp) + 1)),
-      code_next_(0),
-      code_first_(0),
-      code_old_(0),
-      next_in_(nullptr),
-      avail_in_(0),
-      bits_left_(0),
-      code_store_(0) {}
+      code_end_(static_cast<uint16_t>((1 << code_exp) + 1)) {}
 
 CFX_LZWDecompressor::~CFX_LZWDecompressor() = default;
 
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.h b/core/fxcodec/gif/cfx_lzwdecompressor.h
index 60c9388..6c7a2b9 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor.h
+++ b/core/fxcodec/gif/cfx_lzwdecompressor.h
@@ -40,26 +40,28 @@
   size_t* DecompressedNextForTest() { return &decompressed_next_; }
 
  private:
+  // Use Create() instead.
   CFX_LZWDecompressor(uint8_t color_exp, uint8_t code_exp);
+
   void ClearTable();
   void AddCode(uint16_t prefix_code, uint8_t append_char);
   bool DecodeString(uint16_t code);
   uint32_t ExtractData(uint8_t* dest_buf, uint32_t dest_size);
 
-  uint8_t code_size_;
-  uint8_t code_size_cur_;
-  uint16_t code_color_end_;
-  uint16_t code_clear_;
-  uint16_t code_end_;
-  uint16_t code_next_;
-  uint8_t code_first_;
+  const uint8_t code_size_;
+  uint8_t code_size_cur_ = 0;
+  const uint16_t code_color_end_;
+  const uint16_t code_clear_;
+  const uint16_t code_end_;
+  uint16_t code_next_ = 0;
+  uint8_t code_first_ = 0;
   std::vector<uint8_t, FxAllocAllocator<uint8_t>> decompressed_;
-  size_t decompressed_next_;
-  uint16_t code_old_;
-  const uint8_t* next_in_;
-  uint32_t avail_in_;
-  uint8_t bits_left_;
-  uint32_t code_store_;
+  size_t decompressed_next_ = 0;
+  uint16_t code_old_ = 0;
+  const uint8_t* next_in_ = nullptr;
+  uint32_t avail_in_ = 0;
+  uint8_t bits_left_ = 0;
+  uint32_t code_store_ = 0;
   CodeEntry code_table_[GIF_MAX_LZW_CODE];
 };