Add ObservedPtrs to catch issues in SaveData
BUG=chromium:756427
Change-Id: I90c7065ec5a467cb954cdf3e1d6954a0b0655d4e
Reviewed-on: https://pdfium-review.googlesource.com/15630
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 70d3990..fb1afe9 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -672,9 +672,10 @@
return;
CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get());
- ASSERT(pWidget);
- CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm();
- pInterForm->OnCalculate(pWidget->GetFormField());
+ if (pWidget) {
+ CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm();
+ pInterForm->OnCalculate(pWidget->GetFormField());
+ }
m_bNotifying = false;
}
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 76434a5..4174ae4 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -139,10 +139,15 @@
WideString sOldValue = m_pWidget->GetValue();
WideString sNewValue = pWnd->GetText();
+ CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get());
+ CFFL_TextField::ObservedPtr observed_this(this);
m_pWidget->SetValue(sNewValue, false);
- m_pWidget->ResetFieldAppearance(true);
- m_pWidget->UpdateField();
- SetChangeMark();
+ if (observed_widget)
+ m_pWidget->ResetFieldAppearance(true);
+ if (observed_widget)
+ m_pWidget->UpdateField();
+ if (observed_this)
+ SetChangeMark();
}
void CFFL_TextField::GetActionData(CPDFSDK_PageView* pPageView,