Previously, njs_xml_node_attr_handler() and qjs_xml_node_attr_handler()
passed the result of xmlHasProp() directly to xmlRemoveProp(). Because
xmlHasProp() can return an XML_ATTRIBUTE_DECL node from the DTD when
the element does not have an own attribute of that name, xmlRemoveProp()
read past the end of the declaration structure.
Only call xmlRemoveProp() when xmlHasProp() returns an
XML_ATTRIBUTE_NODE.
The issues were introduced in
7d656627 (0.7.11) and
cec9a165 (0.8.10).
attr = xmlHasProp(current, name_c);
- if (attr != NULL) {
+ if (attr != NULL && attr->type == XML_ATTRIBUTE_NODE) {
xmlRemoveProp(attr);
}
if (JS_IsNullOrUndefined(setval)) {
attr = xmlHasProp(node->node, name);
- if (attr != NULL) {
+ if (attr != NULL && attr->type == XML_ATTRIBUTE_NODE) {
xmlRemoveProp(attr);
}