Use fxcrt::MakeFakeUniquePtr() in a few more places.
Limit the scope of the fake pointer as well.
Change-Id: I6f78a0207a5b236458fc48419244227b6c041d53
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/99411
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
index 4354ffd..2a2a9ff 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -141,10 +141,8 @@
std::unique_ptr<CPDF_PageObject> CPDF_PageObjectHolder::RemovePageObject(
CPDF_PageObject* pPageObj) {
- fxcrt::FakeUniquePtr<CPDF_PageObject> p(pPageObj);
-
- auto it =
- std::find(std::begin(m_PageObjectList), std::end(m_PageObjectList), p);
+ auto it = std::find(std::begin(m_PageObjectList), std::end(m_PageObjectList),
+ fxcrt::MakeFakeUniquePtr(pPageObj));
if (it == std::end(m_PageObjectList))
return nullptr;
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index 2f35101..bf3fe09 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -171,9 +171,8 @@
m_pFormFillEnv->KillFocusAnnot({}); // May invoke JS, invalidating pAnnot.
if (pObserved) {
- fxcrt::FakeUniquePtr<const CPDFSDK_Annot> fake_unique_annot(pAnnot);
auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(),
- fake_unique_annot);
+ fxcrt::MakeFakeUniquePtr(pAnnot));
if (it != m_SDKAnnotArray.end())
m_SDKAnnotArray.erase(it);
}
@@ -597,10 +596,7 @@
}
bool CPDFSDK_PageView::IsValidSDKAnnot(const CPDFSDK_Annot* p) const {
- if (!p)
- return false;
- fxcrt::FakeUniquePtr<const CPDFSDK_Annot> fake_unique_p(p);
- return pdfium::Contains(m_SDKAnnotArray, fake_unique_p);
+ return p && pdfium::Contains(m_SDKAnnotArray, fxcrt::MakeFakeUniquePtr(p));
}
CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index f00357c..b8093c6 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -402,8 +402,8 @@
void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) {
DCHECK_EQ(pWnd->m_pParent, this);
- auto it = std::find(m_Children.begin(), m_Children.end(),
- fxcrt::FakeUniquePtr<CPWL_Wnd>(pWnd));
+ auto it =
+ std::find(m_Children.begin(), m_Children.end(), MakeFakeUniquePtr(pWnd));
if (it == m_Children.end())
return;
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index e7c23e7..0dcaa61 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -403,7 +403,7 @@
}
void CJS_App::CancelProc(GlobalTimer* pTimer) {
- m_Timers.erase(fxcrt::FakeUniquePtr<GlobalTimer>(pTimer));
+ m_Timers.erase(fxcrt::MakeFakeUniquePtr(pTimer));
}
void CJS_App::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) {