summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_pageview.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-07-24 11:38:31 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-07-24 19:42:23 +0000
commitbfa2a97ca9f5026ceb8e8c2ce23cfc3c3e8b38a1 (patch)
treea97d91eb40560bae12721841a8fa6985aab42d8f /fpdfsdk/cpdfsdk_pageview.cpp
parent585f4f0828d2bef2ea132a19e28f21af67bb6bdd (diff)
downloadpdfium-bfa2a97ca9f5026ceb8e8c2ce23cfc3c3e8b38a1.tar.xz
Observe Annot destruction in CPDFSDK_PageView::DeleteAnnot
Run test XFA-Only, since that's where the issue occurs, and the textual output is different for non-xfa. Fix a few lifetime issue in pdfium_test.cc unearthed by this test (doc must outlive pages now held in formfill info). Bug: 735912 Change-Id: Icc9e6a967c32ece67d897117896c973bb16a1515 Reviewed-on: https://pdfium-review.googlesource.com/8510 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_pageview.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_pageview.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index 4780d87780..06761a5806 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -175,17 +175,23 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) {
bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
if (!pAnnot)
return false;
+
CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
if (!pPage || (pPage->GetContext()->GetDocType() != XFA_DocType::Static &&
pPage->GetContext()->GetDocType() != XFA_DocType::Dynamic)) {
return false;
}
+ CPDFSDK_Annot::ObservedPtr pObserved(pAnnot);
if (GetFocusAnnot() == pAnnot)
- m_pFormFillEnv->KillFocusAnnot(0);
- CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr();
- if (pAnnotHandler)
- pAnnotHandler->ReleaseAnnot(pAnnot);
+ m_pFormFillEnv->KillFocusAnnot(0); // May invoke JS, invalidating pAnnot.
+
+ if (pObserved) {
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandler =
+ m_pFormFillEnv->GetAnnotHandlerMgr();
+ if (pAnnotHandler)
+ pAnnotHandler->ReleaseAnnot(pObserved.Get());
+ }
auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot);
if (it != m_SDKAnnotArray.end())