CPDF_FormControl::m_pWidgetDict is never null. Its callers have all previously de-referenced it prior to passing it into the constructor. -- Also remove uncalled GetInteractiveForm() method Change-Id: Idc954bc54075d72352afc59fc01a2e5a8c738e6a Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79853 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index 42f7e91..d00edc1 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -40,7 +40,9 @@ CPDF_Dictionary* pWidgetDict) : m_pField(pField), m_pWidgetDict(pWidgetDict), - m_pForm(m_pField->GetForm()) {} + m_pForm(m_pField->GetForm()) { + DCHECK(m_pWidgetDict); +} CPDF_FormControl::~CPDF_FormControl() = default; @@ -125,9 +127,6 @@ CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() const { - if (!m_pWidgetDict) - return Invert; - ByteString csH = m_pWidgetDict->GetStringFor("H", "I"); for (size_t i = 0; i < pdfium::size(kHighlightModes); ++i) { if (csH == kHighlightModes[i]) @@ -137,8 +136,7 @@ } CPDF_ApSettings CPDF_FormControl::GetMK() const { - return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictFor("MK") - : nullptr); + return CPDF_ApSettings(m_pWidgetDict->GetDictFor("MK")); } bool CPDF_FormControl::HasMKEntry(const ByteString& csEntry) const { @@ -180,9 +178,6 @@ } CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() const { - if (!m_pWidgetDict) - return CPDF_DefaultAppearance(); - if (m_pWidgetDict->KeyExist("DA")) return CPDF_DefaultAppearance(m_pWidgetDict->GetStringFor("DA")); @@ -243,8 +238,6 @@ } int CPDF_FormControl::GetControlAlignment() const { - if (!m_pWidgetDict) - return 0; if (m_pWidgetDict->KeyExist("Q")) return m_pWidgetDict->GetIntegerFor("Q", 0);
diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h index 00fbb78..93422fc 100644 --- a/core/fpdfdoc/cpdf_formcontrol.h +++ b/core/fpdfdoc/cpdf_formcontrol.h
@@ -39,9 +39,6 @@ ~CPDF_FormControl(); CPDF_FormField::Type GetType() const { return m_pField->GetType(); } - const CPDF_InteractiveForm* GetInteractiveForm() const { - return m_pForm.Get(); - } CPDF_FormField* GetField() const { return m_pField.Get(); } CPDF_Dictionary* GetWidget() const { return m_pWidgetDict.Get(); } CFX_FloatRect GetRect() const;
diff --git a/core/fpdfdoc/cpdf_interactiveform.cpp b/core/fpdfdoc/cpdf_interactiveform.cpp index 8d0ad7b..37b3aa8 100644 --- a/core/fpdfdoc/cpdf_interactiveform.cpp +++ b/core/fpdfdoc/cpdf_interactiveform.cpp
@@ -875,12 +875,8 @@ if (pKids) { for (size_t i = 0; i < pKids->size(); i++) { CPDF_Dictionary* pKid = pKids->GetDictAt(i); - if (!pKid) - continue; - if (pKid->GetNameFor("Subtype") != "Widget") - continue; - - AddControl(pField, pKid); + if (pKid && pKid->GetNameFor("Subtype") == "Widget") + AddControl(pField, pKid); } } else { if (pFieldDict->GetNameFor("Subtype") == "Widget") @@ -891,6 +887,7 @@ CPDF_FormControl* CPDF_InteractiveForm::AddControl( CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict) { + DCHECK(pWidgetDict); const auto it = m_ControlMap.find(pWidgetDict); if (it != m_ControlMap.end()) return it->second.get();