mirror of
https://github.com/php/php-src.git
synced 2024-11-23 01:44:06 +08:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-15868: Assertion failure in xml_parse_into_struct after exception Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
This commit is contained in:
commit
e7b022ea17
46
ext/xml/tests/gh15868.phpt
Normal file
46
ext/xml/tests/gh15868.phpt
Normal file
@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
GH-15868 (Assertion failure in xml_parse_into_struct after exception)
|
||||
--EXTENSIONS--
|
||||
xml
|
||||
--FILE--
|
||||
<?php
|
||||
$parser = xml_parser_create();
|
||||
xml_set_element_handler($parser,
|
||||
function ($parser, $name, $attrs) {
|
||||
throw new Error('stop 1');
|
||||
}, function ($parser, $name) {
|
||||
}
|
||||
);
|
||||
try {
|
||||
xml_parse_into_struct($parser, "<container/>", $values, $tags);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
$parser = xml_parser_create();
|
||||
xml_set_element_handler($parser,
|
||||
function ($parser, $name, $attrs) {
|
||||
}, function ($parser, $name) {
|
||||
throw new Error('stop 2');
|
||||
}
|
||||
);
|
||||
try {
|
||||
xml_parse_into_struct($parser, "<container/>", $values, $tags);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
$parser = xml_parser_create();
|
||||
xml_set_character_data_handler($parser, function() {
|
||||
throw new Error('stop 3');
|
||||
});
|
||||
try {
|
||||
xml_parse_into_struct($parser, "<root><![CDATA[x]]></root>", $values, $tags);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
stop 1
|
||||
stop 2
|
||||
stop 3
|
@ -626,7 +626,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha
|
||||
zval_ptr_dtor(&args[2]);
|
||||
}
|
||||
|
||||
if (!Z_ISUNDEF(parser->data)) {
|
||||
if (!Z_ISUNDEF(parser->data) && !EG(exception)) {
|
||||
if (parser->level <= XML_MAXLEVEL) {
|
||||
zval tag, atr;
|
||||
int atcnt = 0;
|
||||
@ -697,7 +697,7 @@ void xml_endElementHandler(void *userData, const XML_Char *name)
|
||||
zval_ptr_dtor(&args[1]);
|
||||
}
|
||||
|
||||
if (!Z_ISUNDEF(parser->data)) {
|
||||
if (!Z_ISUNDEF(parser->data) && !EG(exception)) {
|
||||
zval tag;
|
||||
|
||||
if (parser->lastwasopen) {
|
||||
@ -746,7 +746,7 @@ void xml_characterDataHandler(void *userData, const XML_Char *s, int len)
|
||||
zval_ptr_dtor(&args[1]);
|
||||
}
|
||||
|
||||
if (Z_ISUNDEF(parser->data)) {
|
||||
if (Z_ISUNDEF(parser->data) || EG(exception)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user