mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix #81351: xml_parse may fail, but has no error code
The fix for bug #73151[1] cured the symptoms, but not the root cause,
namely xmlParse() must not be called recursively. Since that bugfix
also messed up the error handling, we basically revert it (but also
simplify the return), and then prevent calling the parser recursively.
[1] <f2a8a8c068
>
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Closes GH-7363.
This commit is contained in:
parent
78cbe56e68
commit
80a377e69b
5 changed files with 44 additions and 9 deletions
|
@ -1416,6 +1416,10 @@ PHP_FUNCTION(xml_parse)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (parser->isparsing) {
|
||||
php_error_docref(NULL, E_WARNING, "Parser must not be called recursively");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
parser->isparsing = 1;
|
||||
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal);
|
||||
parser->isparsing = 0;
|
||||
|
@ -1467,6 +1471,10 @@ PHP_FUNCTION(xml_parse_into_struct)
|
|||
XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler);
|
||||
XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
|
||||
|
||||
if (parser->isparsing) {
|
||||
php_error_docref(NULL, E_WARNING, "Parser must not be called recursively");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
parser->isparsing = 1;
|
||||
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, 1);
|
||||
parser->isparsing = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue