From d7fb8a34ac027e8ebf53c218fef2fd6a061d88cf Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 14 Jan 2008 19:00:28 +0000 Subject: 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 --- src/common/crypto.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/common/crypto.c') 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; } -- cgit v1.2.3-54-g00ecf