From 9282819ce86f93ca46a73adb43b5c50289f4c99e Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 17 Aug 2016 13:28:51 -0700 Subject: Speculative fix for DrawAppearance issue If the control is not found in the CPDF_InterForm control map then ::GetControlByDict can return nullptr. This nullptr was not handled in CPDFSDK_Widget::GetFormField(). This Cl propagates the nullptr back up to the caller methods and fixes the returns as needed. This is a speculative crash to fix the referenced bug. BUG=chromium:637953 Review-Url: https://codereview.chromium.org/2256783003 --- fpdfsdk/cpdfsdk_widget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index 3da86aa11f..a36014c924 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -519,7 +519,8 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( } int CPDFSDK_Widget::GetFieldType() const { - return GetFormField()->GetFieldType(); + CPDF_FormField* pField = GetFormField(); + return pField ? pField->GetFieldType() : FIELDTYPE_UNKNOWN; } FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { @@ -554,7 +555,8 @@ CFX_ByteString CPDFSDK_Widget::GetSubType() const { } CPDF_FormField* CPDFSDK_Widget::GetFormField() const { - return GetFormControl()->GetField(); + CPDF_FormControl* pControl = GetFormControl(); + return pControl ? pControl->GetField() : nullptr; } CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { -- cgit v1.2.3