summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-01-14 19:00:28 +0000
committerNick Mathewson <nickm@torproject.org>2008-01-14 19:00:28 +0000
commitd7fb8a34ac027e8ebf53c218fef2fd6a061d88cf (patch)
tree5abb7179792e939cf441a1a4869ab4464896200e /src/common/crypto.c
parent581ba51c5ce623e182a8dc5233c13df4e86f3d7b (diff)
downloadtor-d7fb8a34ac027e8ebf53c218fef2fd6a061d88cf.tar.gz
tor-d7fb8a34ac027e8ebf53c218fef2fd6a061d88cf.zip
r17613@catbus: nickm | 2008-01-14 13:52:44 -0500
Do not segfault if symetric key generation somehow fails in crypto_hybrid_encrypt. svn:r13132
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;
}