summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_widgetacc.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-10 17:03:35 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 17:03:35 +0000
commit54f86140d436ce2f457dc588f5b2c183d4e94452 (patch)
treefcdbc16dc792cdcfba7b28f607cec84a742d8e93 /xfa/fxfa/cxfa_widgetacc.cpp
parenta408ac86ecad7086b3af6aa04d994cc4da16f52d (diff)
downloadpdfium-54f86140d436ce2f457dc588f5b2c183d4e94452.tar.xz
Verify GetOrCreate results are checked
This CL updates users of the GetOrCreate* methods to verify that the value returned is not null before accessing. Change-Id: I4a9fd29a26d5e4ec792ca3671c9868828e53d46e Reviewed-on: https://pdfium-review.googlesource.com/22652 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_widgetacc.cpp')
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index f1067249f7..0c55bd6ce6 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -258,7 +258,7 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
CXFA_Node* pUIChild = nullptr;
CXFA_Ui* pUI =
pNode->JSObject()->GetOrCreateProperty<CXFA_Ui>(0, XFA_Element::Ui);
- CXFA_Node* pChild = pUI->GetFirstChild();
+ CXFA_Node* pChild = pUI ? pUI->GetFirstChild() : nullptr;
for (; pChild; pChild = pChild->GetNextSibling()) {
XFA_Element eChildType = pChild->GetElementType();
if (eChildType == XFA_Element::Extras ||
@@ -303,11 +303,14 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
if (!pUIChild) {
if (eUIType == XFA_Element::Unknown) {
eUIType = XFA_Element::TextEdit;
- defValue->JSObject()->GetOrCreateProperty<CXFA_Text>(0,
- XFA_Element::Text);
+ if (defValue) {
+ defValue->JSObject()->GetOrCreateProperty<CXFA_Text>(0,
+ XFA_Element::Text);
+ }
}
return {eWidgetType,
- pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)};
+ pUI ? pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)
+ : nullptr};
}
if (eUIType != XFA_Element::Unknown)
@@ -350,7 +353,8 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
eValueType = XFA_Element::Text;
break;
}
- defValue->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType);
+ if (defValue)
+ defValue->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType);
return {eWidgetType, pUIChild};
}