summaryrefslogtreecommitdiff
path: root/ext/dom/dom_iterators.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2004-02-17 11:13:47 +0000
committerRob Richards <rrichards@php.net>2004-02-17 11:13:47 +0000
commitec2ea131fbee3bfe682eafcd75ff87ae550d8ad6 (patch)
tree896b392a8ab2729032d34e68f8dc1adb9a91bc42 /ext/dom/dom_iterators.c
parent0ecd198dc5b4a7328020c02b1147bd5eab593eb3 (diff)
downloadphp-git-ec2ea131fbee3bfe682eafcd75ff87ae550d8ad6.tar.gz
implement clone functionality to fix segfault
DomNode->clone() creates new doc proxy if document is cloned remove printf from xpath fix remaining invalid object state issues
Diffstat (limited to 'ext/dom/dom_iterators.c')
-rw-r--r--ext/dom/dom_iterators.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c
index 6e027c243e..78c2492312 100644
--- a/ext/dom/dom_iterators.c
+++ b/ext/dom/dom_iterators.c
@@ -268,33 +268,35 @@ 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->ht == NULL) {
- if (objmap->nodetype == DOM_NODESET) {
- nodeht = HASH_OF(objmap->baseobjptr);
- zend_hash_internal_pointer_reset(nodeht);
- if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {
- curattr = *entry;
- curattr->refcount++;
- }
- } else {
- nodep = (xmlNode *)dom_object_get_node(objmap->baseobj);
- if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) {
- if (objmap->nodetype == XML_ATTRIBUTE_NODE) {
- curnode = (xmlNodePtr) nodep->properties;
- } else {
- curnode = (xmlNodePtr) nodep->children;
+ if (objmap != NULL) {
+ if (objmap->ht == NULL) {
+ if (objmap->nodetype == DOM_NODESET) {
+ nodeht = HASH_OF(objmap->baseobjptr);
+ zend_hash_internal_pointer_reset(nodeht);
+ if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {
+ curattr = *entry;
+ curattr->refcount++;
}
} else {
- if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
- nodep = xmlDocGetRootElement((xmlDoc *) nodep);
+ nodep = (xmlNode *)dom_object_get_node(objmap->baseobj);
+ if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) {
+ if (objmap->nodetype == XML_ATTRIBUTE_NODE) {
+ curnode = (xmlNodePtr) nodep->properties;
+ } else {
+ curnode = (xmlNodePtr) nodep->children;
+ }
} else {
- nodep = nodep->children;
+ if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
+ nodep = xmlDocGetRootElement((xmlDoc *) nodep);
+ } else {
+ nodep = nodep->children;
+ }
+ curnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &curindex, 0);
}
- curnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &curindex, 0);
}
+ } else {
+ curnode = php_dom_libxml_hash_iter(objmap->ht, 0);
}
- } else {
- curnode = php_dom_libxml_hash_iter(objmap->ht, 0);
}
if (curnode) {