Skip to content

Commit

Permalink
Fixed memory leak (ext/hash/tests/mhash_001.phpt failure)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Aug 19, 2020
1 parent 9883fec commit 736c5dc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}
/* }}} */

Expand Down

0 comments on commit 736c5dc

Please sign in to comment.