summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2009-09-28 16:37:01 +0200
committerSebastian Hahn <sebastian@torproject.org>2009-12-12 03:29:44 +0100
commit3807db001d71c51e53c1897ae067671f5b771f2f (patch)
tree6c6f648f072d24e7bbf554de12519b27cd9ef888 /src/common/crypto.c
parent4afdb79051f7b1caba49877fb57be60bda9d4514 (diff)
downloadtor-3807db001d71c51e53c1897ae067671f5b771f2f.tar.gz
tor-3807db001d71c51e53c1897ae067671f5b771f2f.zip
*_free functions now accept NULL
Some *_free functions threw asserts when passed NULL. Now all of them accept NULL as input and perform no action when called that way. This gains us consistence for our free functions, and allows some code simplifications where an explicit null check is no longer necessary.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 4c880f6b6f..4d17a8f216 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -400,7 +400,8 @@ crypto_new_pk_env(void)
void
crypto_free_pk_env(crypto_pk_env_t *env)
{
- tor_assert(env);
+ if (!env)
+ return;
if (--env->refs > 0)
return;
@@ -463,7 +464,8 @@ crypto_new_cipher_env(void)
void
crypto_free_cipher_env(crypto_cipher_env_t *env)
{
- tor_assert(env);
+ if (!env)
+ return;
tor_assert(env->cipher);
aes_free_cipher(env->cipher);
@@ -1528,6 +1530,8 @@ crypto_new_digest256_env(digest_algorithm_t algorithm)
void
crypto_free_digest_env(crypto_digest_env_t *digest)
{
+ if (!digest)
+ return;
memset(digest, 0, sizeof(crypto_digest_env_t));
tor_free(digest);
}
@@ -1899,7 +1903,8 @@ crypto_expand_key_material(const char *key_in, size_t key_in_len,
void
crypto_dh_free(crypto_dh_env_t *dh)
{
- tor_assert(dh);
+ if (!dh)
+ return;
tor_assert(dh->dh);
DH_free(dh->dh);
tor_free(dh);