tony2001 Mon Feb 12 21:13:01 2007 UTC Modified files: /php-src/ext/simplexml simplexml.c /php-src/ext/simplexml/tests bug40451.phpt Log: MFB: #40451 (addAttribute() may crash when used with non-existent child node) http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.227&r2=1.228&diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.227 php-src/ext/simplexml/simplexml.c:1.228 --- php-src/ext/simplexml/simplexml.c:1.227 Thu Jan 18 23:23:50 2007 +++ php-src/ext/simplexml/simplexml.c Mon Feb 12 21:13:01 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.227 2007/01/18 23:23:50 helly Exp $ */ +/* $Id: simplexml.c,v 1.228 2007/02/12 21:13:01 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1586,7 +1586,7 @@ node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - if (node->type != XML_ELEMENT_NODE) { + if (node && node->type != XML_ELEMENT_NODE) { node = node->parent; } @@ -2396,7 +2396,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.227 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.228 $"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug40451.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/simplexml/tests/bug40451.phpt diff -u /dev/null php-src/ext/simplexml/tests/bug40451.phpt:1.2 --- /dev/null Mon Feb 12 21:13:01 2007 +++ php-src/ext/simplexml/tests/bug40451.phpt Mon Feb 12 21:13:01 2007 @@ -0,0 +1,22 @@ +--TEST-- +Bug #40451 (addAttribute() may crash when used with non-existent child node) +--FILE-- +<?php + +$string = <<<XML +<?xml version="1.0"?> + <Host enable="true"> + <Name>host.server.com</Name> + </Host> +XML; + +$xml = simplexml_load_string((binary)$string); + +$add = $xml->addChild('Host'); +$add->Host->addAttribute('enable', 'true'); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: SimpleXMLElement::addAttribute(): Unable to locate parent Element in %s on line %d +Done
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php