summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index f76eb9d01d..6f7ffd3f58 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -858,8 +858,10 @@ crypto_pk_public_hybrid_encrypt(crypto_pk_env_t *env,
crypto_free_cipher_env(cipher);
return outlen + symlen;
err:
- memset(buf, 0, pkeylen);
- tor_free(buf);
+ if (buf) {
+ memset(buf, 0, pkeylen);
+ tor_free(buf);
+ }
if (cipher) crypto_free_cipher_env(cipher);
return -1;
}