Make WordPress Core

Changeset 48322


Ignore:
Timestamp:
07/05/2020 03:20:16 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/link-parse-opml.php

    r47785 r48322  
    9595// Free up memory used by the XML parser.
    9696xml_parser_free( $xml_parser );
     97unset( $xml_parser );
  • trunk/src/wp-includes/IXR/class-IXR-message.php

    r45054 r48322  
    111111
    112112        $final = false;
     113
    113114        do {
    114115            if (strlen($this->message) <= $chunk_size) {
    115116                $final = true;
    116117            }
     118
    117119            $part = substr($this->message, 0, $chunk_size);
    118120            $this->message = substr($this->message, $chunk_size);
     121
    119122            if (!xml_parse($this->_parser, $part, $final)) {
     123                xml_parser_free($this->_parser);
     124                unset($this->_parser);
    120125                return false;
    121126            }
     127
    122128            if ($final) {
    123129                break;
    124130            }
    125131        } while (true);
     132
    126133        xml_parser_free($this->_parser);
     134        unset($this->_parser);
    127135
    128136        // Grab the error messages, if any
  • trunk/src/wp-includes/atomlib.php

    r45932 r48322  
    183183
    184184        xml_parser_free($parser);
     185        unset($parser);
    185186
    186187        restore_error_handler();
  • trunk/src/wp-includes/feed.php

    r48200 r48322  
    565565    $code = xml_get_error_code( $parser );
    566566    xml_parser_free( $parser );
     567    unset( $parser );
    567568
    568569    if ( ! $code ) {
  • trunk/src/wp-includes/rss.php

    r47902 r48322  
    9595
    9696        xml_parser_free( $this->parser );
     97        unset( $this->parser );
    9798
    9899        $this->normalize();
Note: See TracChangeset for help on using the changeset viewer.