Skip to content

Commit

Permalink
Fix return value of xml_parse(_into_struct) for recursive parsing
Browse files Browse the repository at this point in the history
As of PHP 8.0.0, these functions are supposed to return int, so we
cannot return `false`.  Since calling the parser recursively is a
programmer error, we throw an `Error` in this case.

Cf. <#7363>.
  • Loading branch information
cmb69 committed Aug 13, 2021
1 parent 2c6177a commit 15e5cf8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions ext/xml/tests/bug73135.phpt
Expand Up @@ -21,10 +21,6 @@ HERE;
xml_parse($parser, $xml);
?>
--EXPECTF--
Warning: xml_parse(): Parser must not be called recursively in %s%ebug73135.php on line %d

Warning: xml_parse(): Parser must not be called recursively in %s%ebug73135.php on line %d

Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d

Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d
Fatal error: Uncaught Error: Parser must not be called recursively in %s:%d
Stack trace:
%a
4 changes: 2 additions & 2 deletions ext/xml/xml.c
Expand Up @@ -1258,8 +1258,8 @@ PHP_FUNCTION(xml_parse)

parser = Z_XMLPARSER_P(pind);
if (parser->isparsing) {
php_error_docref(NULL, E_WARNING, "Parser must not be called recursively");
RETURN_FALSE;
zend_throw_error(NULL, "Parser must not be called recursively");
RETURN_THROWS();
}
parser->isparsing = 1;
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal);
Expand Down

0 comments on commit 15e5cf8

Please sign in to comment.