diff options
| author | Rob Richards <rrichards@php.net> | 2006-03-03 20:15:10 +0000 |
|---|---|---|
| committer | Rob Richards <rrichards@php.net> | 2006-03-03 20:15:10 +0000 |
| commit | 65211cddcc0fecbf7b0321cb250f5b7538428cf2 (patch) | |
| tree | bdeec77d7bc555f94f627f40c0c442f93355b4b6 /ext/dom/dom_iterators.c | |
| parent | a1024ce67972714079bc591444a59870c780e350 (diff) | |
| download | php-git-65211cddcc0fecbf7b0321cb250f5b7538428cf2.tar.gz | |
fix crashes using notations and entity decls
add test
Diffstat (limited to 'ext/dom/dom_iterators.c')
| -rw-r--r-- | ext/dom/dom_iterators.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index 75b123b252..f7b84fc750 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -200,7 +200,8 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) curobj = iterator->curobj; intern = (dom_object *)zend_object_store_get_object(curobj TSRMLS_CC); if (intern != NULL && intern->ptr != NULL) { - if (objmap->ht == NULL) { + if (objmap->nodetype != XML_ENTITY_NODE && + objmap->nodetype != XML_NOTATION_NODE) { if (objmap->nodetype == DOM_NODESET) { nodeht = HASH_OF(objmap->baseobjptr); zend_hash_move_forward(nodeht); @@ -210,12 +211,14 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) } } else { curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node; - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { + if (objmap->nodetype == XML_ATTRIBUTE_NODE || + objmap->nodetype == XML_ELEMENT_NODE) { curnode = curnode->next; } else { /* Nav the tree evey time as this is LIVE */ basenode = dom_object_get_node(objmap->baseobj); - if (basenode && (basenode->type == XML_DOCUMENT_NODE || basenode->type == XML_HTML_DOCUMENT_NODE)) { + if (basenode && (basenode->type == XML_DOCUMENT_NODE || + basenode->type == XML_HTML_DOCUMENT_NODE)) { basenode = xmlDocGetRootElement((xmlDoc *) basenode); } else { basenode = basenode->children; @@ -225,9 +228,9 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) } } else { if (objmap->nodetype == XML_ENTITY_NODE) { - curnode = php_dom_libxml_hash_iter(objmap->ht, iter->index); + curnode = php_dom_libxml_hash_iter(objmap->ht, iter->index - 1); } else { - curnode = php_dom_libxml_notation_iter(objmap->ht, iter->index); + curnode = php_dom_libxml_notation_iter(objmap->ht, iter->index - 1); } } } @@ -269,7 +272,8 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object TS intern = (dom_object *)zend_object_store_get_object(object TSRMLS_CC); objmap = (dom_nnodemap_object *)intern->ptr; if (objmap != NULL) { - if (objmap->ht == NULL) { + if (objmap->nodetype != XML_ENTITY_NODE && + objmap->nodetype != XML_NOTATION_NODE) { if (objmap->nodetype == DOM_NODESET) { nodeht = HASH_OF(objmap->baseobjptr); zend_hash_internal_pointer_reset(nodeht); @@ -295,7 +299,11 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object TS } } } else { - curnode = php_dom_libxml_hash_iter(objmap->ht, 0); + if (objmap->nodetype == XML_ENTITY_NODE) { + curnode = php_dom_libxml_hash_iter(objmap->ht, 0); + } else { + curnode = php_dom_libxml_notation_iter(objmap->ht, 0); + } } } |
