mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
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:
parent
b0703f3749
commit
f14f0c1ddf
@ -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 );
|
||||
|
@ -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') {
|
||||
|
@ -182,6 +182,7 @@ class AtomParser {
|
||||
fclose($fp);
|
||||
|
||||
xml_parser_free($parser);
|
||||
unset($parser);
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
|
@ -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 ) {
|
||||
|
@ -94,6 +94,7 @@ class MagpieRSS {
|
||||
}
|
||||
|
||||
xml_parser_free( $this->parser );
|
||||
unset( $this->parser );
|
||||
|
||||
$this->normalize();
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user