From 54f86140d436ce2f457dc588f5b2c183d4e94452 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 10 Jan 2018 17:03:35 +0000 Subject: 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 Commit-Queue: dsinclair --- xfa/fxfa/cxfa_widgetacc.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'xfa/fxfa/cxfa_widgetacc.cpp') 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 CreateUIChild(CXFA_Node* pNode) { CXFA_Node* pUIChild = nullptr; CXFA_Ui* pUI = pNode->JSObject()->GetOrCreateProperty(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 CreateUIChild(CXFA_Node* pNode) { if (!pUIChild) { if (eUIType == XFA_Element::Unknown) { eUIType = XFA_Element::TextEdit; - defValue->JSObject()->GetOrCreateProperty(0, - XFA_Element::Text); + if (defValue) { + defValue->JSObject()->GetOrCreateProperty(0, + XFA_Element::Text); + } } return {eWidgetType, - pUI->JSObject()->GetOrCreateProperty(0, eUIType)}; + pUI ? pUI->JSObject()->GetOrCreateProperty(0, eUIType) + : nullptr}; } if (eUIType != XFA_Element::Unknown) @@ -350,7 +353,8 @@ std::pair CreateUIChild(CXFA_Node* pNode) { eValueType = XFA_Element::Text; break; } - defValue->JSObject()->GetOrCreateProperty(0, eValueType); + if (defValue) + defValue->JSObject()->GetOrCreateProperty(0, eValueType); return {eWidgetType, pUIChild}; } -- cgit v1.2.3