From 8fa82794ffc2763e9fa1fc9d401c8e9a14d7c67f Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 11 Jan 2017 09:32:33 -0800 Subject: Annotation deleted while retrieving it in JS Widgets as returned from GetWidgets() can pop out of existence unexpectedly, so always return observed pointers. This extends the same pattern used elsewhere in the file to all occurrences. BUG=679642 Review-Url: https://codereview.chromium.org/2624933002 --- fpdfsdk/javascript/Document.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'fpdfsdk/javascript/Document.cpp') diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 29f9764806..7e4dc260f2 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -506,12 +506,16 @@ bool Document::removeField(IJS_Context* cc, CJS_Runtime* pRuntime = pContext->GetJSRuntime(); CFX_WideString sFieldName = params[0].ToCFXWideString(pRuntime); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - std::vector widgets; + std::vector widgets; pInterForm->GetWidgets(sFieldName, &widgets); if (widgets.empty()) return true; - for (CPDFSDK_Widget* pWidget : widgets) { + for (const auto& pAnnot : widgets) { + CPDFSDK_Widget* pWidget = static_cast(pAnnot.Get()); + if (!pWidget) + continue; + CFX_FloatRect rcAnnot = pWidget->GetRect(); --rcAnnot.left; --rcAnnot.bottom; -- cgit v1.2.3