Return IPDF_Page* from CPDFSDK_FormFillEnvironment::GetCurrentPage()
Prevent use of FPDF_PAGE from leaking out below the fpdfsdk/ layer.
Change-Id: Ib24149e9bd61f035f0bc6e6e5fa510901ef024a6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96271
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index ab5342d..7d67ae3 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -125,14 +125,14 @@
#ifdef PDF_ENABLE_V8
CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetCurrentView() {
- IPDF_Page* pPage = IPDFPageFromFPDFPage(GetCurrentPage());
+ IPDF_Page* pPage = GetCurrentPage();
return pPage ? GetOrCreatePageView(pPage) : nullptr;
}
-FPDF_PAGE CPDFSDK_FormFillEnvironment::GetCurrentPage() const {
+IPDF_Page* CPDFSDK_FormFillEnvironment::GetCurrentPage() const {
if (m_pInfo && m_pInfo->FFI_GetCurrentPage) {
- return m_pInfo->FFI_GetCurrentPage(
- m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc.Get()));
+ return IPDFPageFromFPDFPage(m_pInfo->FFI_GetCurrentPage(
+ m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc.Get())));
}
return nullptr;
}
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index e90b751..72889df 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -146,7 +146,7 @@
#ifdef PDF_ENABLE_V8
CPDFSDK_PageView* GetCurrentView();
- FPDF_PAGE GetCurrentPage() const;
+ IPDF_Page* GetCurrentPage() const;
WideString GetLanguage();
WideString GetPlatform();
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 84ddc8e..dbd984e 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -18,7 +18,6 @@
#include "core/fpdfdoc/cpdf_formfield.h"
#include "core/fpdfdoc/cpdf_interactiveform.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
-#include "fpdfsdk/cpdfsdk_helpers.h"
#include "fpdfsdk/cpdfsdk_interactiveform.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
#include "fpdfsdk/cpdfsdk_widget.h"
@@ -2491,7 +2490,7 @@
if (nCount == 1) {
pWidget = pForm->GetWidget(pFormField->GetControl(0));
} else {
- IPDF_Page* pPage = IPDFPageFromFPDFPage(m_pFormFillEnv->GetCurrentPage());
+ IPDF_Page* pPage = m_pFormFillEnv->GetCurrentPage();
if (!pPage)
return CJS_Result::Failure(JSMessage::kBadObjectError);
CPDFSDK_PageView* pCurPageView = m_pFormFillEnv->GetOrCreatePageView(pPage);