cvs: php4 /ext/domxml php_domxml.c

From: Date: Thu, 03 Jan 2002 13:20:04 +0000
Subject: cvs: php4 /ext/domxml php_domxml.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8918@lists.php.net to get a copy of this message
mfischer Thu Jan 3 08:20:04 2002 EDT Modified files: /php4/ext/domxml php_domxml.c Log: - domxml_node_add_child(): Perform deep copy before adding child to prevent double memory freeing. # I wonder how this could work before. Index: php4/ext/domxml/php_domxml.c diff -u php4/ext/domxml/php_domxml.c:1.90 php4/ext/domxml/php_domxml.c:1.91 --- php4/ext/domxml/php_domxml.c:1.90 Thu Dec 20 09:40:43 2001 +++ php4/ext/domxml/php_domxml.c Thu Jan 3 08:20:04 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_domxml.c,v 1.90 2001/12/20 14:40:43 mfischer Exp $ */ +/* $Id: php_domxml.c,v 1.91 2002/01/03 13:20:04 mfischer Exp $ */ #ifdef HAVE_CONFIG_H @@ -1604,7 +1604,7 @@ PHP_FUNCTION(domxml_node_add_child) { zval *id, *rv, *node; - xmlNodePtr child, nodep; + xmlNodePtr child, nodep, new_child; int ret; DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep); @@ -1615,7 +1615,12 @@ DOMXML_GET_OBJ(child, node, le_domxmlnodep); - child = xmlAddChild(nodep, child); + if (NULL == (new_child = xmlCopyNode(child, 1))) { + php_error(E_WARNING, "%s() unable to clone node", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } + + child = xmlAddChild(nodep, new_child); if (NULL == child) { php_error(E_WARNING, "%s() couldn't add child", get_active_function_name(TSRMLS_C));

« previous php.cvs (#8918) next »