@@ -992,6 +992,7 @@ PHP_FUNCTION(sodium_crypto_sign_publickey_from_secretkey)
992
992
993
993
if (crypto_sign_ed25519_sk_to_pk ((unsigned char * ) ZSTR_VAL (publickey ),
994
994
(const unsigned char * ) secretkey ) != 0 ) {
995
+ zend_string_efree (publickey );
995
996
zend_throw_exception (sodium_exception_ce ,
996
997
"internal error" , 0 );
997
998
RETURN_THROWS ();
@@ -2475,6 +2476,7 @@ PHP_FUNCTION(sodium_crypto_kx_seed_keypair)
2475
2476
crypto_generichash (sk , crypto_kx_SECRETKEYBYTES ,
2476
2477
seed , crypto_kx_SEEDBYTES , NULL , 0 );
2477
2478
if (crypto_scalarmult_base (pk , sk ) != 0 ) {
2479
+ zend_string_efree (keypair );
2478
2480
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
2479
2481
RETURN_THROWS ();
2480
2482
}
@@ -2496,6 +2498,7 @@ PHP_FUNCTION(sodium_crypto_kx_keypair)
2496
2498
pk = sk + crypto_kx_SECRETKEYBYTES ;
2497
2499
randombytes_buf (sk , crypto_kx_SECRETKEYBYTES );
2498
2500
if (crypto_scalarmult_base (pk , sk ) != 0 ) {
2501
+ zend_string_efree (keypair );
2499
2502
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
2500
2503
RETURN_THROWS ();
2501
2504
}
@@ -2672,6 +2675,7 @@ PHP_FUNCTION(sodium_crypto_auth)
2672
2675
if (crypto_auth ((unsigned char * ) ZSTR_VAL (mac ),
2673
2676
(const unsigned char * ) msg , msg_len ,
2674
2677
(const unsigned char * ) key ) != 0 ) {
2678
+ zend_string_efree (mac );
2675
2679
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
2676
2680
RETURN_THROWS ();
2677
2681
}
@@ -2731,6 +2735,7 @@ PHP_FUNCTION(sodium_crypto_sign_ed25519_sk_to_curve25519)
2731
2735
2732
2736
if (crypto_sign_ed25519_sk_to_curve25519 ((unsigned char * ) ZSTR_VAL (ecdhkey ),
2733
2737
(const unsigned char * ) eddsakey ) != 0 ) {
2738
+ zend_string_efree (ecdhkey );
2734
2739
zend_throw_exception (sodium_exception_ce , "conversion failed" , 0 );
2735
2740
RETURN_THROWS ();
2736
2741
}
@@ -2758,6 +2763,7 @@ PHP_FUNCTION(sodium_crypto_sign_ed25519_pk_to_curve25519)
2758
2763
2759
2764
if (crypto_sign_ed25519_pk_to_curve25519 ((unsigned char * ) ZSTR_VAL (ecdhkey ),
2760
2765
(const unsigned char * ) eddsakey ) != 0 ) {
2766
+ zend_string_efree (ecdhkey );
2761
2767
zend_throw_exception (sodium_exception_ce , "conversion failed" , 0 );
2762
2768
RETURN_THROWS ();
2763
2769
}
@@ -3036,6 +3042,7 @@ PHP_FUNCTION(sodium_pad)
3036
3042
#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6 )
3037
3043
if (sodium_pad (NULL , (unsigned char * ) ZSTR_VAL (padded ), unpadded_len ,
3038
3044
(size_t ) blocksize , xpadded_len + 1U ) != 0 ) {
3045
+ zend_string_efree (padded );
3039
3046
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
3040
3047
RETURN_THROWS ();
3041
3048
}
0 commit comments