[PHP-CVS] cvs: php4 /ext/dom element.c node.c php_dom.c
sterlingThu Jun 5 14:54:26 2003 EDT Modified files: /php4/ext/dom element.c node.c php_dom.c Log: fix a bunch of memory overruns, and uninitialized variable uses fixes crash on sample script rob sent me Index: php4/ext/dom/element.c diff -u php4/ext/dom/element.c:1.1 php4/ext/dom/element.c:1.2 --- php4/ext/dom/element.c:1.1 Thu Jun 5 13:06:52 2003 +++ php4/ext/dom/element.c Thu Jun 5 14:54:25 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: element.c,v 1.1 2003/06/05 17:06:52 rrichards Exp $ */ +/* $Id: element.c,v 1.2 2003/06/05 18:54:25 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -65,7 +65,7 @@ xmlNodePtr nodep = NULL, oldnode = NULL; dom_object *intern; char *name, *value = NULL; - int name_len, value_len; + int name_len, value_len = 0; id = getThis(); Index: php4/ext/dom/node.c diff -u php4/ext/dom/node.c:1.1 php4/ext/dom/node.c:1.2 --- php4/ext/dom/node.c:1.1 Thu Jun 5 13:06:52 2003 +++ php4/ext/dom/node.c Thu Jun 5 14:54:25 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: node.c,v 1.1 2003/06/05 17:06:52 rrichards Exp $ */ +/* $Id: node.c,v 1.2 2003/06/05 18:54:25 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -982,6 +982,10 @@ return; } + if (!PZVAL_IS_REF(node)) { + zval_add_ref(node); + } + DOM_GET_OBJ(child, node, xmlNodePtr); if (dom_hierarchy(nodep, child) == FAILURE) { Index: php4/ext/dom/php_dom.c diff -u php4/ext/dom/php_dom.c:1.2 php4/ext/dom/php_dom.c:1.3 --- php4/ext/dom/php_dom.c:1.2 Thu Jun 5 13:48:25 2003 +++ php4/ext/dom/php_dom.c Thu Jun 5 14:54:25 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: php_dom.c,v 1.2 2003/06/05 17:48:25 sterling Exp $ */ +/* $Id: php_dom.c,v 1.3 2003/06/05 18:54:25 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -698,9 +698,11 @@ { xmlDtdPtr extSubset, intSubset; xmlDocPtr docp; + if (!node) { return; } + switch (node-type) { case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/dom element.c node.c php_dom.c
The following part seems to cause memleaks. Is this really a right fix? + if (!PZVAL_IS_REF(node)) { + zval_add_ref(node); + } + /home/koizumi/src/php5/ext/dom/php_dom.c(814) : Freeing 0x0831D19C (32 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/Zend/zend_hash.c(150) : Actual location (location was rel ayed) /home/koizumi/src/php5/ext/dom/php_dom.c(813) : Freeing 0x0831D13C (44 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/ext/dom/php_dom.c(798) : Freeing 0x08314B24 (24 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php Moriyoshi -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/dom element.c node.c php_dom.c
On Thu, 2003-06-05 at 15:16, Moriyoshi Koizumi wrote: The following part seems to cause memleaks. Is this really a right fix? + if (!PZVAL_IS_REF(node)) { + zval_add_ref(node); + } + /home/koizumi/src/php5/ext/dom/php_dom.c(814) : Freeing 0x0831D19C (32 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/Zend/zend_hash.c(150) : Actual location (location was rel ayed) /home/koizumi/src/php5/ext/dom/php_dom.c(813) : Freeing 0x0831D13C (44 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/ext/dom/php_dom.c(798) : Freeing 0x08314B24 (24 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php Yep. But it doesn't crash. :) -sterling Moriyoshi -- People can have the Model T in any colour -- so long as it's black. - Henry Ford -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/dom element.c node.c php_dom.c
On Thu, 2003-06-05 at 15:08, Sterling Hughes wrote: On Thu, 2003-06-05 at 15:16, Moriyoshi Koizumi wrote: The following part seems to cause memleaks. Is this really a right fix? + if (!PZVAL_IS_REF(node)) { + zval_add_ref(node); + } + /home/koizumi/src/php5/ext/dom/php_dom.c(814) : Freeing 0x0831D19C (32 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/Zend/zend_hash.c(150) : Actual location (location was rel ayed) /home/koizumi/src/php5/ext/dom/php_dom.c(813) : Freeing 0x0831D13C (44 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/ext/dom/php_dom.c(798) : Freeing 0x08314B24 (24 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php Yep. But it doesn't crash. :) (just a note that this will probably be fixed differently, but for now, its a fix). -Sterling -sterling Moriyoshi -- People can have the Model T in any colour -- so long as it's black. - Henry Ford -- People can have the Model T in any colour -- so long as it's black. - Henry Ford -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/dom element.c node.c php_dom.c
Sterling Hughes [EMAIL PROTECTED] wrote: On Thu, 2003-06-05 at 15:16, Moriyoshi Koizumi wrote: The following part seems to cause memleaks. Is this really a right fix? + if (!PZVAL_IS_REF(node)) { + zval_add_ref(node); + } + /home/koizumi/src/php5/ext/dom/php_dom.c(814) : Freeing 0x0831D19C (32 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/Zend/zend_hash.c(150) : Actual location (location was rel ayed) /home/koizumi/src/php5/ext/dom/php_dom.c(813) : Freeing 0x0831D13C (44 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php /home/koizumi/src/php5/ext/dom/php_dom.c(798) : Freeing 0x08314B24 (24 bytes), script=/home/koizumi/src/php5/ext/dom/tests/dom001.php Yep. But it doesn't crash. :) :) What's the script like that Rob sent to you? Hopefully I can help.. Moriyoshi -sterling Moriyoshi -- People can have the Model T in any colour -- so long as it's black. - Henry Ford -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php