From 736c5dca100813da4a32dab78f524b8b2f9c92e4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 19 Aug 2020 09:30:08 +0300 Subject: [PATCH] Fixed memory leak (ext/hash/tests/mhash_001.phpt failure) --- ext/hash/hash.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 3f01ebcce6..64be043362 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -1202,7 +1202,7 @@ PHP_FUNCTION(mhash) if (algorithm >= 0 && algorithm < MHASH_NUM_ALGOS) { struct mhash_bc_entry algorithm_lookup = mhash_to_hash[algorithm]; if (algorithm_lookup.hash_name) { - algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 1); + algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 0); } } @@ -1211,6 +1211,10 @@ PHP_FUNCTION(mhash) } else { php_hash_do_hash(return_value, algo, data, data_len, 1, 0); } + + if (algo) { + zend_string_release(algo); + } } /* }}} */ -- 2.50.1