Make WordPress Core


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.