From 1b6f2719873e749b3fc9b2beb829e70e33c34ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Thu, 18 Aug 2022 10:31:52 +0200 Subject: [PATCH] Fix memory leak of scrypt() --- php_scrypt.c | 5 ++--- tests/scrypt_vectors.phpt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/php_scrypt.c b/php_scrypt.c index 9f3bba2..50df498 100644 --- a/php_scrypt.c +++ b/php_scrypt.c @@ -199,11 +199,11 @@ PHP_FUNCTION(scrypt) php_hash_bin2hex(hex, buf, keyLength); efree(buf); hex[keyLength*2] = '\0'; - RETURN_STRINGL(hex, keyLength * 2); + RETVAL_STRINGL(hex, keyLength * 2); efree(hex); } else { buf[keyLength] = '\0'; - RETURN_STRINGL((char *)buf, keyLength); + RETVAL_STRINGL((char *)buf, keyLength); efree(buf); } } @@ -280,5 +280,4 @@ PHP_FUNCTION(scrypt_pickparams) add_assoc_long(return_value, "n", phpN); add_assoc_long(return_value, "r", phpR); add_assoc_long(return_value, "p", phpP); - return; } diff --git a/tests/scrypt_vectors.phpt b/tests/scrypt_vectors.phpt index a2660b8..a1dd1bb 100644 --- a/tests/scrypt_vectors.phpt +++ b/tests/scrypt_vectors.phpt @@ -5,7 +5,7 @@ Test scrypt KDF using test vectors. --INI-- memory_limit=2G --FILE-- -