mirror of
git://develop.git.wordpress.org/
synced 2025-02-20 14:44:55 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@48322 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e3df130089
commit
b5b613f8bb
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user