Fix unowned ptr exclusions in core/fpdfapi

Convert T* pointers to another smart pointer type as flagged by
the compiler plugin.

Change-Id: I3915c14baaee6215617b84352d61b39f80723aa4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107132
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_stringarchivestream.h b/core/fpdfapi/edit/cpdf_stringarchivestream.h
index 1306343..3907e2c 100644
--- a/core/fpdfapi/edit/cpdf_stringarchivestream.h
+++ b/core/fpdfapi/edit/cpdf_stringarchivestream.h
@@ -7,6 +7,7 @@
 
 #include "core/fxcrt/fx_stream.h"
 #include "core/fxcrt/fx_string_wrappers.h"
+#include "core/fxcrt/unowned_ptr.h"
 
 class CPDF_StringArchiveStream final : public IFX_ArchiveStream {
  public:
@@ -18,7 +19,7 @@
   FX_FILESIZE CurrentOffset() const override;
 
  private:
-  fxcrt::ostringstream* stream_;
+  UnownedPtr<fxcrt::ostringstream> stream_;
 };
 
 #endif  // CORE_FPDFAPI_EDIT_CPDF_STRINGARCHIVESTREAM_H_
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
index 5404207..43ae781 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
@@ -232,7 +232,7 @@
     return false;
 
   struct MayBeSignature {
-    const CPDF_Dictionary* parent;
+    RetainPtr<const CPDF_Dictionary> parent;
     RetainPtr<CPDF_Object> contents;
   };
 
@@ -255,7 +255,8 @@
         // Temporary skip it, to prevent signature corruption.
         // It will be decrypted on next interations, if this is not contents of
         // signature dictionary.
-        may_be_sign_dictionaries.push({parent_dict.Get(), std::move(child)});
+        may_be_sign_dictionaries.push(
+            {std::move(parent_dict), std::move(child)});
         walker.SkipWalkIntoCurrentObject();
         continue;
       }
diff --git a/core/fpdfapi/parser/object_tree_traversal_util.cpp b/core/fpdfapi/parser/object_tree_traversal_util.cpp
index e1a0d52..58b7e7b 100644
--- a/core/fpdfapi/parser/object_tree_traversal_util.cpp
+++ b/core/fpdfapi/parser/object_tree_traversal_util.cpp
@@ -17,6 +17,7 @@
 #include "core/fpdfapi/parser/cpdf_document.h"
 #include "core/fpdfapi/parser/cpdf_reference.h"
 #include "core/fpdfapi/parser/cpdf_stream.h"
+#include "core/fxcrt/unowned_ptr.h"
 #include "third_party/base/check.h"
 #include "third_party/base/containers/contains.h"
 
@@ -169,7 +170,7 @@
     return it != object_number_map_.end() ? it->second : 0;
   }
 
-  const CPDF_Document* const document_;
+  UnownedPtr<const CPDF_Document> const document_;
 
   // Queue of objects to traverse.
   // - Pointers in the queue are non-null.
diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.h b/core/fpdfapi/render/cpdf_progressiverenderer.h
index 67170fc..7af65a0 100644
--- a/core/fpdfapi/render/cpdf_progressiverenderer.h
+++ b/core/fpdfapi/render/cpdf_progressiverenderer.h
@@ -53,7 +53,7 @@
   std::unique_ptr<CPDF_RenderStatus> m_pRenderStatus;
   CFX_FloatRect m_ClipRect;
   uint32_t m_LayerIndex = 0;
-  CPDF_RenderContext::Layer* m_pCurrentLayer = nullptr;
+  UnownedPtr<CPDF_RenderContext::Layer> m_pCurrentLayer;
   CPDF_PageObjectHolder::const_iterator m_LastObjectRendered;
 };
 
diff --git a/core/fpdfapi/render/cpdf_rendershading.cpp b/core/fpdfapi/render/cpdf_rendershading.cpp
index ce7543b..3dc6f79 100644
--- a/core/fpdfapi/render/cpdf_rendershading.cpp
+++ b/core/fpdfapi/render/cpdf_rendershading.cpp
@@ -27,6 +27,7 @@
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/span_util.h"
+#include "core/fxcrt/unowned_ptr.h"
 #include "core/fxge/cfx_defaultrenderdevice.h"
 #include "core/fxge/cfx_fillrenderoptions.h"
 #include "core/fxge/cfx_path.h"
@@ -767,7 +768,7 @@
 
   int max_delta;
   CFX_Path path;
-  CFX_RenderDevice* pDevice;
+  UnownedPtr<CFX_RenderDevice> pDevice;
   int bNoPathSmooth;
   int alpha;
   CoonColor patch_colors[4];