Return unique_ptr<>s from fxcodec/

Review-Url: https://codereview.chromium.org/2572843002
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index cabf3d3..fd5267b 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -27,20 +27,13 @@
 #include "core/fxcodec/fx_codec.h"
 #include "core/fxcrt/fx_ext.h"
 
-CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
-    const uint8_t* src_buf,
-    uint32_t src_size,
-    int width,
-    int height,
-    const CPDF_Dictionary* pParams);
-
 namespace {
 
 const uint32_t kMaxNestedArrayLevel = 512;
 const uint32_t kMaxWordBuffer = 256;
 const FX_STRSIZE kMaxStringLength = 32767;
 
-uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder,
+uint32_t DecodeAllScanlines(std::unique_ptr<CCodec_ScanlineDecoder> pDecoder,
                             uint8_t*& dest_buf,
                             uint32_t& dest_size) {
   if (!pDecoder)
@@ -50,10 +43,9 @@
   int width = pDecoder->GetWidth();
   int height = pDecoder->GetHeight();
   int pitch = (width * ncomps * bpc + 7) / 8;
-  if (height == 0 || pitch > (1 << 30) / height) {
-    delete pDecoder;
+  if (height == 0 || pitch > (1 << 30) / height)
     return FX_INVALID_OFFSET;
-  }
+
   dest_buf = FX_Alloc2D(uint8_t, pitch, height);
   dest_size = pitch * height;  // Safe since checked alloc returned.
   for (int row = 0; row < height; row++) {
@@ -63,9 +55,7 @@
 
     FXSYS_memcpy(dest_buf + row * pitch, pLine, pitch);
   }
-  uint32_t srcoff = pDecoder->GetSrcOffset();
-  delete pDecoder;
-  return srcoff;
+  return pDecoder->GetSrcOffset();
 }
 
 uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf,
@@ -77,9 +67,9 @@
                                 uint8_t*& dest_buf,
                                 uint32_t& dest_size) {
   if (decoder == "CCITTFaxDecode" || decoder == "CCF") {
-    CCodec_ScanlineDecoder* pDecoder =
+    std::unique_ptr<CCodec_ScanlineDecoder> pDecoder =
         FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam);
-    return DecodeAllScanlines(pDecoder, dest_buf, dest_size);
+    return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size);
   }
   if (decoder == "ASCII85Decode" || decoder == "A85")
     return A85Decode(src_buf, limit, dest_buf, dest_size);
@@ -94,11 +84,11 @@
                                     dest_size);
   }
   if (decoder == "DCTDecode" || decoder == "DCT") {
-    CCodec_ScanlineDecoder* pDecoder =
+    std::unique_ptr<CCodec_ScanlineDecoder> pDecoder =
         CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
             src_buf, limit, width, height, 0,
             !pParam || pParam->GetIntegerFor("ColorTransform", 1));
-    return DecodeAllScanlines(pDecoder, dest_buf, dest_size);
+    return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size);
   }
   if (decoder == "RunLengthDecode" || decoder == "RL")
     return RunLengthDecode(src_buf, limit, dest_buf, dest_size);
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 6398c71..884b5c5 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -245,7 +245,7 @@
   return std::min(i + 1, src_size);
 }
 
-CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
+std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFaxDecoder(
     const uint8_t* src_buf,
     uint32_t src_size,
     int width,
@@ -273,7 +273,7 @@
       Columns, Rows);
 }
 
-CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
+std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFlateDecoder(
     const uint8_t* src_buf,
     uint32_t src_size,
     int width,
@@ -288,9 +288,8 @@
     Colors = pParams->GetIntegerFor("Colors", 1);
     BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8);
     Columns = pParams->GetIntegerFor("Columns", 1);
-    if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) {
+    if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns))
       return nullptr;
-    }
   }
   return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder(
       src_buf, src_size, width, height, nComps, bpc, predictor, Colors,
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h
index 4d99f15..dc8ecf0 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.h
+++ b/core/fpdfapi/parser/fpdf_parser_decode.h
@@ -7,8 +7,11 @@
 #ifndef CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_
 #define CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_
 
+#include <memory>
+
 #include "core/fxcrt/fx_basic.h"
 
+class CCodec_ScanlineDecoder;
 class CPDF_Dictionary;
 
 // Indexed by 8-bit char code, contains unicode code points.
@@ -45,6 +48,22 @@
                          uint8_t*& dest_buf,
                          uint32_t& dest_size);
 
+std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFaxDecoder(
+    const uint8_t* src_buf,
+    uint32_t src_size,
+    int width,
+    int height,
+    const CPDF_Dictionary* pParams);
+
+std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFlateDecoder(
+    const uint8_t* src_buf,
+    uint32_t src_size,
+    int width,
+    int height,
+    int nComps,
+    int bpc,
+    const CPDF_Dictionary* pParams);
+
 // Public for testing.
 uint32_t A85Decode(const uint8_t* src_buf,
                    uint32_t src_size,
diff --git a/core/fpdfapi/render/fpdf_render_loadimage.cpp b/core/fpdfapi/render/fpdf_render_loadimage.cpp
index f690f68..085077f 100644
--- a/core/fpdfapi/render/fpdf_render_loadimage.cpp
+++ b/core/fpdfapi/render/fpdf_render_loadimage.cpp
@@ -17,6 +17,7 @@
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
 #include "core/fpdfapi/parser/cpdf_document.h"
+#include "core/fpdfapi/parser/fpdf_parser_decode.h"
 #include "core/fpdfapi/render/cpdf_pagerendercache.h"
 #include "core/fpdfapi/render/cpdf_renderstatus.h"
 #include "core/fxcodec/fx_codec.h"
@@ -513,22 +514,6 @@
   return pCompData;
 }
 
-CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
-    const uint8_t* src_buf,
-    uint32_t src_size,
-    int width,
-    int height,
-    const CPDF_Dictionary* pParams);
-
-CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
-    const uint8_t* src_buf,
-    uint32_t src_size,
-    int width,
-    int height,
-    int nComps,
-    int bpc,
-    const CPDF_Dictionary* pParams);
-
 int CPDF_DIBSource::CreateDecoder() {
   const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder();
   if (decoder.IsEmpty())
@@ -556,22 +541,21 @@
   uint32_t src_size = m_pStreamAcc->GetSize();
   const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam();
   if (decoder == "CCITTFaxDecode") {
-    m_pDecoder.reset(FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width,
-                                              m_Height, pParams));
+    m_pDecoder = FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, m_Height,
+                                          pParams);
   } else if (decoder == "FlateDecode") {
-    m_pDecoder.reset(FPDFAPI_CreateFlateDecoder(
-        src_data, src_size, m_Width, m_Height, m_nComponents, m_bpc, pParams));
+    m_pDecoder = FPDFAPI_CreateFlateDecoder(
+        src_data, src_size, m_Width, m_Height, m_nComponents, m_bpc, pParams);
   } else if (decoder == "RunLengthDecode") {
-    m_pDecoder.reset(CPDF_ModuleMgr::Get()
-                         ->GetCodecModule()
-                         ->GetBasicModule()
-                         ->CreateRunLengthDecoder(src_data, src_size, m_Width,
-                                                  m_Height, m_nComponents,
-                                                  m_bpc));
+    m_pDecoder = CPDF_ModuleMgr::Get()
+                     ->GetCodecModule()
+                     ->GetBasicModule()
+                     ->CreateRunLengthDecoder(src_data, src_size, m_Width,
+                                              m_Height, m_nComponents, m_bpc);
   } else if (decoder == "DCTDecode") {
-    m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
+    m_pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
         src_data, src_size, m_Width, m_Height, m_nComponents,
-        !pParams || pParams->GetIntegerFor("ColorTransform", 1)));
+        !pParams || pParams->GetIntegerFor("ColorTransform", 1));
     if (!m_pDecoder) {
       bool bTransform = false;
       int comps;
@@ -623,8 +607,8 @@
             return 0;
         }
         m_bpc = bpc;
-        m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
-            src_data, src_size, m_Width, m_Height, m_nComponents, bTransform));
+        m_pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
+            src_data, src_size, m_Width, m_Height, m_nComponents, bTransform);
       }
     }
   }
diff --git a/core/fpdfapi/render/render_int.h b/core/fpdfapi/render/render_int.h
index 276370d..311ba8a 100644
--- a/core/fpdfapi/render/render_int.h
+++ b/core/fpdfapi/render/render_int.h
@@ -173,13 +173,4 @@
   int m_Status;
 };
 
-CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
-    const uint8_t* src_buf,
-    uint32_t src_size,
-    int width,
-    int height,
-    int nComps,
-    int bpc,
-    const CPDF_Dictionary* pParams);
-
 #endif  // CORE_FPDFAPI_RENDER_RENDER_INT_H_
diff --git a/core/fxcodec/codec/ccodec_basicmodule.h b/core/fxcodec/codec/ccodec_basicmodule.h
index 1c3f4d1..425b5d7 100644
--- a/core/fxcodec/codec/ccodec_basicmodule.h
+++ b/core/fxcodec/codec/ccodec_basicmodule.h
@@ -7,18 +7,21 @@
 #ifndef CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
 #define CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
 
+#include <memory>
+
 #include "core/fxcrt/fx_system.h"
 
 class CCodec_ScanlineDecoder;
 
 class CCodec_BasicModule {
  public:
-  CCodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
-                                                 uint32_t src_size,
-                                                 int width,
-                                                 int height,
-                                                 int nComps,
-                                                 int bpc);
+  std::unique_ptr<CCodec_ScanlineDecoder> CreateRunLengthDecoder(
+      const uint8_t* src_buf,
+      uint32_t src_size,
+      int width,
+      int height,
+      int nComps,
+      int bpc);
 };
 
 #endif  // CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_faxmodule.h b/core/fxcodec/codec/ccodec_faxmodule.h
index 18b9bb6..ce9e97b 100644
--- a/core/fxcodec/codec/ccodec_faxmodule.h
+++ b/core/fxcodec/codec/ccodec_faxmodule.h
@@ -7,22 +7,24 @@
 #ifndef CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
 #define CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
 
+#include <memory>
+
 #include "core/fxcrt/fx_system.h"
 
 class CCodec_ScanlineDecoder;
 
 class CCodec_FaxModule {
  public:
-  CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
-                                        uint32_t src_size,
-                                        int width,
-                                        int height,
-                                        int K,
-                                        bool EndOfLine,
-                                        bool EncodedByteAlign,
-                                        bool BlackIs1,
-                                        int Columns,
-                                        int Rows);
+  std::unique_ptr<CCodec_ScanlineDecoder> CreateDecoder(const uint8_t* src_buf,
+                                                        uint32_t src_size,
+                                                        int width,
+                                                        int height,
+                                                        int K,
+                                                        bool EndOfLine,
+                                                        bool EncodedByteAlign,
+                                                        bool BlackIs1,
+                                                        int Columns,
+                                                        int Rows);
 };
 
 #endif  // CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_flatemodule.h b/core/fxcodec/codec/ccodec_flatemodule.h
index ee8fd8d..5178943 100644
--- a/core/fxcodec/codec/ccodec_flatemodule.h
+++ b/core/fxcodec/codec/ccodec_flatemodule.h
@@ -7,22 +7,24 @@
 #ifndef CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
 #define CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
 
+#include <memory>
+
 #include "core/fxcrt/fx_system.h"
 
 class CCodec_ScanlineDecoder;
 
 class CCodec_FlateModule {
  public:
-  CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
-                                        uint32_t src_size,
-                                        int width,
-                                        int height,
-                                        int nComps,
-                                        int bpc,
-                                        int predictor,
-                                        int Colors,
-                                        int BitsPerComponent,
-                                        int Columns);
+  std::unique_ptr<CCodec_ScanlineDecoder> CreateDecoder(const uint8_t* src_buf,
+                                                        uint32_t src_size,
+                                                        int width,
+                                                        int height,
+                                                        int nComps,
+                                                        int bpc,
+                                                        int predictor,
+                                                        int Colors,
+                                                        int BitsPerComponent,
+                                                        int Columns);
   uint32_t FlateOrLZWDecode(bool bLZW,
                             const uint8_t* src_buf,
                             uint32_t src_size,
diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h
index db7f3df..b2ae731 100644
--- a/core/fxcodec/codec/ccodec_jpegmodule.h
+++ b/core/fxcodec/codec/ccodec_jpegmodule.h
@@ -7,6 +7,8 @@
 #ifndef CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
 #define CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
 
+#include <memory>
+
 #include "core/fxcrt/fx_system.h"
 
 class CCodec_ScanlineDecoder;
@@ -21,12 +23,12 @@
  public:
   CCodec_JpegModule() {}
 
-  CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
-                                        uint32_t src_size,
-                                        int width,
-                                        int height,
-                                        int nComps,
-                                        bool ColorTransform);
+  std::unique_ptr<CCodec_ScanlineDecoder> CreateDecoder(const uint8_t* src_buf,
+                                                        uint32_t src_size,
+                                                        int width,
+                                                        int height,
+                                                        int nComps,
+                                                        bool ColorTransform);
   bool LoadInfo(const uint8_t* src_buf,
                 uint32_t src_size,
                 int* width,
diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp
index 2f4a811..aa2ecef 100644
--- a/core/fxcodec/codec/fx_codec.cpp
+++ b/core/fxcodec/codec/fx_codec.cpp
@@ -14,6 +14,7 @@
 #include "core/fxcrt/fx_ext.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "third_party/base/logging.h"
+#include "third_party/base/ptr_util.h"
 
 CCodec_ModuleMgr::CCodec_ModuleMgr()
     : m_pBasicModule(new CCodec_BasicModule),
@@ -302,19 +303,16 @@
   m_Operator = 257 - count;
 }
 
-CCodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(
-    const uint8_t* src_buf,
-    uint32_t src_size,
-    int width,
-    int height,
-    int nComps,
-    int bpc) {
-  std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder(
-      new CCodec_RLScanlineDecoder);
-  if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps,
-                                  bpc)) {
+std::unique_ptr<CCodec_ScanlineDecoder>
+CCodec_BasicModule::CreateRunLengthDecoder(const uint8_t* src_buf,
+                                           uint32_t src_size,
+                                           int width,
+                                           int height,
+                                           int nComps,
+                                           int bpc) {
+  auto pDecoder = pdfium::MakeUnique<CCodec_RLScanlineDecoder>();
+  if (!pDecoder->Create(src_buf, src_size, width, height, nComps, bpc))
     return nullptr;
-  }
 
-  return pRLScanlineDecoder.release();
+  return std::move(pDecoder);
 }
diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp
index 5102c77..62ad38e 100644
--- a/core/fxcodec/codec/fx_codec_fax.cpp
+++ b/core/fxcodec/codec/fx_codec_fax.cpp
@@ -5,10 +5,12 @@
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include <algorithm>
+#include <memory>
 #include <vector>
 
 #include "core/fxcodec/codec/codec_int.h"
 #include "core/fxcodec/fx_codec.h"
+#include "third_party/base/ptr_util.h"
 
 namespace {
 
@@ -580,16 +582,17 @@
   *pbitpos = bitpos;
 }
 
-CCodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(const uint8_t* src_buf,
-                                                        uint32_t src_size,
-                                                        int width,
-                                                        int height,
-                                                        int K,
-                                                        bool EndOfLine,
-                                                        bool EncodedByteAlign,
-                                                        bool BlackIs1,
-                                                        int Columns,
-                                                        int Rows) {
+std::unique_ptr<CCodec_ScanlineDecoder> CCodec_FaxModule::CreateDecoder(
+    const uint8_t* src_buf,
+    uint32_t src_size,
+    int width,
+    int height,
+    int K,
+    bool EndOfLine,
+    bool EncodedByteAlign,
+    bool BlackIs1,
+    int Columns,
+    int Rows) {
   int actual_width = Columns ? Columns : width;
   int actual_height = Rows ? Rows : height;
 
@@ -602,6 +605,7 @@
     return nullptr;
 
   uint32_t pitch = (static_cast<uint32_t>(actual_width) + 31) / 32 * 4;
-  return new CCodec_FaxDecoder(src_buf, src_size, actual_width, actual_height,
-                               pitch, K, EndOfLine, EncodedByteAlign, BlackIs1);
+  return pdfium::MakeUnique<CCodec_FaxDecoder>(
+      src_buf, src_size, actual_width, actual_height, pitch, K, EndOfLine,
+      EncodedByteAlign, BlackIs1);
 }
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index c5611cc..d01b40f 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -8,9 +8,11 @@
 
 #include <algorithm>
 #include <memory>
+#include <utility>
 
 #include "core/fxcodec/fx_codec.h"
 #include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
 #include "third_party/zlib_v128/zlib.h"
 
 extern "C" {
@@ -771,7 +773,7 @@
   return FPDFAPI_FlateGetTotalIn(m_pFlate);
 }
 
-CCodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder(
+std::unique_ptr<CCodec_ScanlineDecoder> CCodec_FlateModule::CreateDecoder(
     const uint8_t* src_buf,
     uint32_t src_size,
     int width,
@@ -782,11 +784,12 @@
     int Colors,
     int BitsPerComponent,
     int Columns) {
-  CCodec_FlateScanlineDecoder* pDecoder = new CCodec_FlateScanlineDecoder;
+  auto pDecoder = pdfium::MakeUnique<CCodec_FlateScanlineDecoder>();
   pDecoder->Create(src_buf, src_size, width, height, nComps, bpc, predictor,
                    Colors, BitsPerComponent, Columns);
-  return pDecoder;
+  return std::move(pDecoder);
 }
+
 uint32_t CCodec_FlateModule::FlateOrLZWDecode(bool bLZW,
                                               const uint8_t* src_buf,
                                               uint32_t src_size,
diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp
index 873b52a..fdfdd4f 100644
--- a/core/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/fxcodec/codec/fx_codec_jpeg.cpp
@@ -7,11 +7,13 @@
 #include <setjmp.h>
 
 #include <memory>
+#include <utility>
 
 #include "core/fxcodec/codec/codec_int.h"
 #include "core/fxcodec/fx_codec.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxge/fx_dib.h"
+#include "third_party/base/ptr_util.h"
 
 extern "C" {
 #undef FAR
@@ -313,21 +315,22 @@
   return (uint32_t)(m_SrcSize - src.bytes_in_buffer);
 }
 
-CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(const uint8_t* src_buf,
-                                                         uint32_t src_size,
-                                                         int width,
-                                                         int height,
-                                                         int nComps,
-                                                         bool ColorTransform) {
+std::unique_ptr<CCodec_ScanlineDecoder> CCodec_JpegModule::CreateDecoder(
+    const uint8_t* src_buf,
+    uint32_t src_size,
+    int width,
+    int height,
+    int nComps,
+    bool ColorTransform) {
   if (!src_buf || src_size == 0)
     return nullptr;
 
-  std::unique_ptr<CCodec_JpegDecoder> pDecoder(new CCodec_JpegDecoder);
+  auto pDecoder = pdfium::MakeUnique<CCodec_JpegDecoder>();
   if (!pDecoder->Create(src_buf, src_size, width, height, nComps,
                         ColorTransform)) {
     return nullptr;
   }
-  return pDecoder.release();
+  return std::move(pDecoder);
 }
 
 bool CCodec_JpegModule::LoadInfo(const uint8_t* src_buf,