Re: Perplexing crash with 5.2.9+ php5ts.dll

Brad Waite <[email protected]>
Newsgroups gmane.comp.php.windows
Message-ID <[email protected]>
Richard Quadling wrote:

> OK, so far so good.
> 
> Now create a simple PHP script which you can run at the command line
> which you think will cause the issue.
> 
> If you can produce a simple test case, then allow us to run it to see
> if it is reproducible.
> 

Okay, found the problem; it's with simplexml_load_string() and with some bad code.

simplexml_load_string() under 5.2.8 will return a proper SimpleXMLElement
object from a non-UTF-16-encoded bit of XML, even though the XML says that it
*is* encoded with UTF-16.

Under 5.2.9+, simplexml_load_string() tosses a warning and returns FALSE.

Apache was crashing because a poorly written SimpleXMLtoArray() function was
recursively calling itself without checking the arguments first.  I suspect it
simply ran out of memory, but I didn't step through it enough times to verify.

Here's a bit of code that can reproduce the "problem":


$xmlstr = '<?xml version="1.0" encoding="utf-16"?><foo
xmlns="http://www.foo.com/service"><bar name="foobar"></bar></foo>';
$xml = simplexml_load_string( $xmlstr, "SimpleXMLElement", LIBXML_NOCDATA );


Why the change in encoding-handling between the PHP versions?  I can't see
anything in the 5.2.9 Changelog that would affect this.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.