summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfview.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-09-07 09:55:37 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-07 09:55:37 -0700
commit1df1efa3921841fb5fc7fc15e8112eed4375de9f (patch)
tree9341f9698575b1451b88e1d826f10212db2d7eaf /fpdfsdk/fpdfview.cpp
parent85a65b310924eacbd2e720162cc7547153b03077 (diff)
downloadpdfium-1df1efa3921841fb5fc7fc15e8112eed4375de9f.tar.xz
Fixup CPDFSDK_PageView and CPDF_Page interactions.
There are several issues when CPDFSDK_PageView and CPDF_Page interact, especially around deletion. This Cl fixes up several places where things go wrong working with these objects. BUG=chromium:632709 Review-Url: https://codereview.chromium.org/2319663002
Diffstat (limited to 'fpdfsdk/fpdfview.cpp')
-rw-r--r--fpdfsdk/fpdfview.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index dee71ac9e2..1c0af1dc10 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -673,9 +673,20 @@ DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) {
#else // PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView =
static_cast<CPDFSDK_PageView*>(pPage->GetView());
- if (pPageView && pPageView->IsLocked()) {
- pPageView->TakeOverPage();
- return;
+ if (pPageView) {
+ if (pPageView->IsLocked()) {
+ pPageView->TakePageOwnership();
+ return;
+ }
+
+ bool owned = pPageView->OwnsPage();
+ // This will delete the |pPageView| object. We must cleanup the PageView
+ // first because it will attempt to reset the View on the |pPage| during
+ // destruction.
+ pPageView->GetSDKDocument()->RemovePageView(pPage);
+ // If the page was owned then the pageview will have deleted the page.
+ if (owned)
+ return;
}
delete pPage;
#endif // PDF_ENABLE_XFA