From a276c2b073f5761761d3caff3ce1326e0117c2eb Mon Sep 17 00:00:00 2001 From: Zachery Stuart Date: Tue, 26 Feb 2019 14:34:15 -0500 Subject: [PATCH] Call xml_parser_free and unset to avoid memory leaks --- phpseclib/Crypt/RSA.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 0f7f8aa2..c2fdc66d 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -1415,9 +1415,14 @@ class Crypt_RSA xml_set_character_data_handler($xml, '_data_handler'); // add to account for "dangling" tags like ... that are sometimes added if (!xml_parse($xml, '' . $key . '')) { + xml_parser_free($xml); + unset($xml); return false; } + xml_parser_free($xml); + unset($xml); + return isset($this->components['modulus']) && isset($this->components['publicExponent']) ? $this->components : false; // from PuTTY's SSHPUBK.C case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: