@@ -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 ();
@@ -2705,6 +2706,7 @@ PHP_FUNCTION(sodium_crypto_kx_seed_keypair)
2705
2706
crypto_generichash (sk , crypto_kx_SECRETKEYBYTES ,
2706
2707
seed , crypto_kx_SEEDBYTES , NULL , 0 );
2707
2708
if (crypto_scalarmult_base (pk , sk ) != 0 ) {
2709
+ zend_string_efree (keypair );
2708
2710
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
2709
2711
RETURN_THROWS ();
2710
2712
}
@@ -2726,6 +2728,7 @@ PHP_FUNCTION(sodium_crypto_kx_keypair)
2726
2728
pk = sk + crypto_kx_SECRETKEYBYTES ;
2727
2729
randombytes_buf (sk , crypto_kx_SECRETKEYBYTES );
2728
2730
if (crypto_scalarmult_base (pk , sk ) != 0 ) {
2731
+ zend_string_efree (keypair );
2729
2732
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
2730
2733
RETURN_THROWS ();
2731
2734
}
@@ -2902,6 +2905,7 @@ PHP_FUNCTION(sodium_crypto_auth)
2902
2905
if (crypto_auth ((unsigned char * ) ZSTR_VAL (mac ),
2903
2906
(const unsigned char * ) msg , msg_len ,
2904
2907
(const unsigned char * ) key ) != 0 ) {
2908
+ zend_string_efree (mac );
2905
2909
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
2906
2910
RETURN_THROWS ();
2907
2911
}
@@ -2961,6 +2965,7 @@ PHP_FUNCTION(sodium_crypto_sign_ed25519_sk_to_curve25519)
2961
2965
2962
2966
if (crypto_sign_ed25519_sk_to_curve25519 ((unsigned char * ) ZSTR_VAL (ecdhkey ),
2963
2967
(const unsigned char * ) eddsakey ) != 0 ) {
2968
+ zend_string_efree (ecdhkey );
2964
2969
zend_throw_exception (sodium_exception_ce , "conversion failed" , 0 );
2965
2970
RETURN_THROWS ();
2966
2971
}
@@ -2988,6 +2993,7 @@ PHP_FUNCTION(sodium_crypto_sign_ed25519_pk_to_curve25519)
2988
2993
2989
2994
if (crypto_sign_ed25519_pk_to_curve25519 ((unsigned char * ) ZSTR_VAL (ecdhkey ),
2990
2995
(const unsigned char * ) eddsakey ) != 0 ) {
2996
+ zend_string_efree (ecdhkey );
2991
2997
zend_throw_exception (sodium_exception_ce , "conversion failed" , 0 );
2992
2998
RETURN_THROWS ();
2993
2999
}
@@ -3292,6 +3298,7 @@ PHP_FUNCTION(sodium_pad)
3292
3298
#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6 )
3293
3299
if (sodium_pad (NULL , (unsigned char * ) ZSTR_VAL (padded ), unpadded_len ,
3294
3300
(size_t ) blocksize , xpadded_len + 1U ) != 0 ) {
3301
+ zend_string_efree (padded );
3295
3302
zend_throw_exception (sodium_exception_ce , "internal error" , 0 );
3296
3303
RETURN_THROWS ();
3297
3304
}
0 commit comments