Skip to content

Commit 2830c3e

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79922: Crash after multiple calls to xml_parser_free()
2 parents 2d08721 + 0af3f49 commit 2830c3e

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ PHP NEWS
2929
. Fixed bug #79930 (array_merge_recursive() crashes when called with array
3030
with single reference). (Nikita)
3131

32+
- XML:
33+
. Fixed bug #79922 (Crash after multiple calls to xml_parser_free()). (cmb)
34+
3235
06 Aug 2020, PHP 7.4.9
3336

3437
- Apache:

ext/xml/tests/bug79922.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #79922 (Crash after multiple calls to xml_parser_free())
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xml')) die('skip xml extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$c=xml_parser_create_ns();
10+
$a=xml_parser_free($c);
11+
$a=xml_parser_free($c);
12+
$c=0;
13+
var_dump($a);
14+
?>
15+
--EXPECTF--
16+
Warning: xml_parser_free(): supplied resource is not a valid XML Parser resource in %s on line %d
17+
bool(false)

ext/xml/xml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
11571157
XML_SetUserData(parser->parser, parser);
11581158

11591159
RETVAL_RES(zend_register_resource(parser, le_xml_parser));
1160-
ZVAL_COPY(&parser->index, return_value);
1160+
ZVAL_COPY_VALUE(&parser->index, return_value);
11611161
}
11621162
/* }}} */
11631163

@@ -1589,7 +1589,7 @@ PHP_FUNCTION(xml_parser_free)
15891589
RETURN_FALSE;
15901590
}
15911591

1592-
if (zend_list_delete(Z_RES(parser->index)) == FAILURE) {
1592+
if (zend_list_close(Z_RES(parser->index)) == FAILURE) {
15931593
RETURN_FALSE;
15941594
}
15951595

0 commit comments

Comments
 (0)