]> granicus.if.org Git - php/commitdiff
Fixed memory leak (ext/hash/tests/mhash_001.phpt failure)
authorDmitry Stogov <dmitry@zend.com>
Wed, 19 Aug 2020 06:30:08 +0000 (09:30 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 19 Aug 2020 06:30:08 +0000 (09:30 +0300)
ext/hash/hash.c

index 3f01ebcce6c4dbf7c133d3130d106aa6838aff22..64be043362ea6373f2e64151de28ba68ec65bd51 100644 (file)
@@ -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);
+       }
 }
 /* }}} */