diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2003-07-23 16:44:27 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2003-07-23 16:44:27 +0000 |
| commit | d197a131dbc07c8d50a391729a5f6379115aa898 (patch) | |
| tree | d9cb0792877b41e8c0fc165fc1f4c1d6fad677ca /ext/domxml/php_domxml.c | |
| parent | 7be9dcd26333b1374a9dfccc3d7e799d046f2e67 (diff) | |
| download | php-git-d197a131dbc07c8d50a391729a5f6379115aa898.tar.gz | |
MFH: Fixed #24609 (segfault when using replace node across different docs)
Patch by: Rob Richards
# This patch somehow did not make it into 4.3.X, so on Rob's request in am
# MFHing it in.
Diffstat (limited to 'ext/domxml/php_domxml.c')
| -rw-r--r-- | ext/domxml/php_domxml.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index b2d132aec2..3a33492224 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -2384,6 +2384,7 @@ PHP_FUNCTION(domxml_node_replace_node) { zval *id, *rv = NULL, *node; xmlNodePtr repnode, nodep, old_repnode; + xmlDocPtr tmpdoc; int ret; DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep); @@ -2394,8 +2395,18 @@ PHP_FUNCTION(domxml_node_replace_node) DOMXML_GET_OBJ(repnode, node, le_domxmlnodep); + tmpdoc = repnode->doc; + old_repnode = xmlReplaceNode(nodep, repnode); + /* ReplaceNode will change the doc for only the first node + so check if doc was changed */ + if (tmpdoc != repnode->doc) { + /* Set doc back to old doc otherwise libxml wont change all sub nodes */ + repnode->doc = tmpdoc; + xmlSetTreeDoc(repnode, old_repnode->doc); + } + DOMXML_RET_OBJ(rv, old_repnode, &ret); } /* }}} */ |
