Add missing nullptr check in CJX_Object::SetCDataImpl()
SetCDataImpl() calls CXFA_Node::GetXMLMappingNode(), which can return
nullptr. Check for this and avoid crashing.
Bug: chromium:1457768
Change-Id: I43aba1a26806928fd5ae7228d61063f7009fb5a9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/109090
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index b9a2160..7542e8a 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -460,13 +460,15 @@
return;
}
+ CFX_XMLElement* elem = ToXMLElement(xfaObj->GetXMLMappingNode());
+ if (!elem) {
+ return;
+ }
+
WideString wsAttrName = WideString::FromASCII(XFA_AttributeToName(eAttr));
if (eAttr == XFA_Attribute::ContentType)
wsAttrName = L"xfa:" + wsAttrName;
-
- CFX_XMLElement* elem = ToXMLElement(xfaObj->GetXMLMappingNode());
elem->SetAttribute(wsAttrName, wsValue);
- return;
}
void CJX_Object::SetAttributeValue(const WideString& wsValue,