Remove const-ref retained stream arguments, step 3.

Change-Id: Ifbdbcc5a1ca9dcab587622386cc03df2a84f83de
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/100390
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/progressive_decoder.cpp b/core/fxcodec/progressive_decoder.cpp
index c5f0109..d79dd1b 100644
--- a/core/fxcodec/progressive_decoder.cpp
+++ b/core/fxcodec/progressive_decoder.cpp
@@ -1491,7 +1491,7 @@
 }
 
 FXCODEC_STATUS ProgressiveDecoder::LoadImageInfo(
-    const RetainPtr<IFX_SeekableReadStream>& pFile,
+    RetainPtr<IFX_SeekableReadStream> pFile,
     FXCODEC_IMAGE_TYPE imageType,
     CFX_DIBAttribute* pAttribute,
     bool bSkipImageTypeCheck) {
@@ -1506,12 +1506,11 @@
     default:
       break;
   }
-  if (!pFile) {
+  m_pFile = std::move(pFile);
+  if (!m_pFile) {
     m_status = FXCODEC_STATUS::kError;
-    m_pFile = nullptr;
     return m_status;
   }
-  m_pFile = pFile;
   m_offSet = 0;
   m_SrcWidth = m_SrcHeight = 0;
   m_SrcComponents = m_SrcBPC = 0;
diff --git a/core/fxcodec/progressive_decoder.h b/core/fxcodec/progressive_decoder.h
index 9a9bbc8..c830900 100644
--- a/core/fxcodec/progressive_decoder.h
+++ b/core/fxcodec/progressive_decoder.h
@@ -69,7 +69,7 @@
   ProgressiveDecoder();
   virtual ~ProgressiveDecoder();
 
-  FXCODEC_STATUS LoadImageInfo(const RetainPtr<IFX_SeekableReadStream>& pFile,
+  FXCODEC_STATUS LoadImageInfo(RetainPtr<IFX_SeekableReadStream> pFile,
                                FXCODEC_IMAGE_TYPE imageType,
                                CFX_DIBAttribute* pAttribute,
                                bool bSkipImageTypeCheck);
diff --git a/core/fxcodec/progressive_decoder_unittest.cpp b/core/fxcodec/progressive_decoder_unittest.cpp
index bce2ac3..cdc0ae1 100644
--- a/core/fxcodec/progressive_decoder_unittest.cpp
+++ b/core/fxcodec/progressive_decoder_unittest.cpp
@@ -72,7 +72,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_BMP, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_BMP, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -105,7 +105,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_BMP, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_BMP, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -136,7 +136,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_BMP, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_BMP, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -168,7 +168,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_BMP, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_BMP, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -200,7 +200,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_BMP, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_BMP, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -232,7 +232,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_BMP, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_BMP, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -271,7 +271,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlyVectorStream>(std::move(input));
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_BMP, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_BMP, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(kWidth, decoder.GetWidth());
@@ -315,7 +315,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_GIF, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_GIF, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -346,7 +346,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_GIF, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_GIF, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -380,7 +380,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_GIF, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_GIF, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(1, decoder.GetWidth());
@@ -411,7 +411,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_GIF, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_GIF, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(4, decoder.GetWidth());
@@ -449,7 +449,7 @@
   auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(kInput);
   CFX_DIBAttribute attr;
   FXCODEC_STATUS status =
-      decoder.LoadImageInfo(source, FXCODEC_IMAGE_GIF, &attr, true);
+      decoder.LoadImageInfo(std::move(source), FXCODEC_IMAGE_GIF, &attr, true);
   ASSERT_EQ(FXCODEC_STATUS::kFrameReady, status);
 
   ASSERT_EQ(4, decoder.GetWidth());
diff --git a/testing/fuzzers/xfa_codec_fuzzer.h b/testing/fuzzers/xfa_codec_fuzzer.h
index 562d183..b14b7d7 100644
--- a/testing/fuzzers/xfa_codec_fuzzer.h
+++ b/testing/fuzzers/xfa_codec_fuzzer.h
@@ -6,6 +6,7 @@
 #define TESTING_FUZZERS_XFA_CODEC_FUZZER_H_
 
 #include <memory>
+#include <utility>
 
 #include "core/fxcodec/fx_codec.h"
 #include "core/fxcodec/progressive_decoder.h"
@@ -26,7 +27,8 @@
     auto source = pdfium::MakeRetain<CFX_ReadOnlySpanStream>(
         pdfium::make_span(data, size));
     CFX_DIBAttribute attr;
-    FXCODEC_STATUS status = decoder->LoadImageInfo(source, type, &attr, true);
+    FXCODEC_STATUS status =
+        decoder->LoadImageInfo(std::move(source), type, &attr, true);
     if (status != FXCODEC_STATUS::kFrameReady)
       return 0;
 
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 750b516..0c424eb 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -313,9 +313,8 @@
 
   auto pImageFileRead =
       pdfium::MakeRetain<CFX_ReadOnlySpanStream>(pAcc->GetSpan());
-
   RetainPtr<CFX_DIBitmap> pDibSource = XFA_LoadImageFromBuffer(
-      pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
+      std::move(pImageFileRead), FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
   m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi};
   return pDibSource;
 }
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 09ddb32..aa30e19 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -144,14 +144,15 @@
 }
 
 RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
-    const RetainPtr<IFX_SeekableReadStream>& pImageFileRead,
+    RetainPtr<IFX_SeekableReadStream> pImageFileRead,
     FXCODEC_IMAGE_TYPE type,
     int32_t& iImageXDpi,
     int32_t& iImageYDpi) {
   auto pProgressiveDecoder = std::make_unique<ProgressiveDecoder>();
 
   CFX_DIBAttribute dibAttr;
-  pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false);
+  pProgressiveDecoder->LoadImageInfo(std::move(pImageFileRead), type, &dibAttr,
+                                     false);
   switch (dibAttr.m_wDPIUnit) {
     case CFX_DIBAttribute::kResUnitCentimeter:
       dibAttr.m_nXDPI = static_cast<int32_t>(dibAttr.m_nXDPI * 2.54f);
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 7e66ed7..e11bca7 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -55,7 +55,7 @@
                    XFA_AttributeValue iVertAlign = XFA_AttributeValue::Top);
 
 RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
-    const RetainPtr<IFX_SeekableReadStream>& pImageFileRead,
+    RetainPtr<IFX_SeekableReadStream> pImageFileRead,
     FXCODEC_IMAGE_TYPE type,
     int32_t& iImageXDpi,
     int32_t& iImageYDpi);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1ad410e..1aac60f 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -511,9 +511,8 @@
     return nullptr;
 
   bNameImage = false;
-  RetainPtr<CFX_DIBitmap> pBitmap =
-      XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi);
-  return pBitmap;
+  return XFA_LoadImageFromBuffer(std::move(pImageFileRead), type, iImageXDpi,
+                                 iImageYDpi);
 }
 
 bool SplitDateTime(const WideString& wsDateTime,