XML-RPC: Explicitly unset the reference to the parser resource after calling `xml_parser_free()` to avoid memory leaks in PHP 7.0.0 or higher.

Props procifer, ayeshrajans.
Fixes #49700.
Built from https://develop.svn.wordpress.org/trunk@48322


git-svn-id: http://core.svn.wordpress.org/trunk@48091 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-05 15:22:01 +00:00
parent b0703f3749
commit f14f0c1ddf
6 changed files with 13 additions and 1 deletions

View File

@ -94,3 +94,4 @@ if ( ! xml_parse( $xml_parser, $opml, true ) ) {
// Free up memory used by the XML parser.
xml_parser_free( $xml_parser );
unset( $xml_parser );

View File

@ -110,20 +110,28 @@ class IXR_Message
$chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
$final = false;
do {
if (strlen($this->message) <= $chunk_size) {
$final = true;
}
$part = substr($this->message, 0, $chunk_size);
$this->message = substr($this->message, $chunk_size);
if (!xml_parse($this->_parser, $part, $final)) {
xml_parser_free($this->_parser);
unset($this->_parser);
return false;
}
if ($final) {
break;
}
} while (true);
xml_parser_free($this->_parser);
unset($this->_parser);
// Grab the error messages, if any
if ($this->messageType == 'fault') {

View File

@ -182,6 +182,7 @@ class AtomParser {
fclose($fp);
xml_parser_free($parser);
unset($parser);
restore_error_handler();

View File

@ -564,6 +564,7 @@ function prep_atom_text_construct( $data ) {
xml_parse( $parser, '<div>' . $data . '</div>', true );
$code = xml_get_error_code( $parser );
xml_parser_free( $parser );
unset( $parser );
if ( ! $code ) {
if ( strpos( $data, '<' ) === false ) {

View File

@ -94,6 +94,7 @@ class MagpieRSS {
}
xml_parser_free( $this->parser );
unset( $this->parser );
$this->normalize();
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48321';
$wp_version = '5.5-alpha-48322';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.