Skip to content

Commit 2479cd6

Browse files
author
Rob Richards
committed
fix crash with entity declarations
1 parent 9ec9210 commit 2479cd6

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

ext/simplexml/simplexml.c

+16-14
Original file line numberDiff line numberDiff line change
@@ -1099,22 +1099,24 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
10991099
if (sxe->iter.type == SXE_ITER_ELEMENT) {
11001100
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
11011101
}
1102-
attr = node ? (xmlAttrPtr)node->properties : NULL;
1103-
zattr = NULL;
1104-
test = sxe->iter.name && sxe->iter.type == SXE_ITER_ATTRLIST;
1105-
while (attr) {
1106-
if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && match_ns(sxe, (xmlNodePtr)attr, sxe->iter.nsprefix, sxe->iter.isprefix)) {
1107-
MAKE_STD_ZVAL(value);
1108-
ZVAL_STRING(value, sxe_xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 0);
1109-
namelen = xmlStrlen(attr->name) + 1;
1110-
if (!zattr) {
1111-
MAKE_STD_ZVAL(zattr);
1112-
array_init(zattr);
1113-
sxe_properties_add(rv, "@attributes", sizeof("@attributes"), zattr TSRMLS_CC);
1102+
if (node->tpye != XML_ENTITY_DECL) {
1103+
attr = node ? (xmlAttrPtr)node->properties : NULL;
1104+
zattr = NULL;
1105+
test = sxe->iter.name && sxe->iter.type == SXE_ITER_ATTRLIST;
1106+
while (attr) {
1107+
if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && match_ns(sxe, (xmlNodePtr)attr, sxe->iter.nsprefix, sxe->iter.isprefix)) {
1108+
MAKE_STD_ZVAL(value);
1109+
ZVAL_STRING(value, sxe_xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 0);
1110+
namelen = xmlStrlen(attr->name) + 1;
1111+
if (!zattr) {
1112+
MAKE_STD_ZVAL(zattr);
1113+
array_init(zattr);
1114+
sxe_properties_add(rv, "@attributes", sizeof("@attributes"), zattr TSRMLS_CC);
1115+
}
1116+
add_assoc_zval_ex(zattr, (char*)attr->name, namelen, value);
11141117
}
1115-
add_assoc_zval_ex(zattr, (char*)attr->name, namelen, value);
1118+
attr = attr->next;
11161119
}
1117-
attr = attr->next;
11181120
}
11191121
}
11201122

0 commit comments

Comments
 (0)