[tor-commits] [tor/master] Remove a couple redundant NULL-checks before crypto_cipher_free

nickm at torproject.org nickm at torproject.org
Fri Mar 30 14:38:35 UTC 2012


commit ab3197c0596de087f43c08bda500fcc36ba2ef20
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Mar 30 10:16:58 2012 -0400

    Remove a couple redundant NULL-checks before crypto_cipher_free
    
    Calling crypto_cipher_free(NULL) is always safe, since (by
    convention) all of our xyz_free() functions treat xyz_free(NULL) as
    a no-op.
    
    Flagged by coverity scan; fixes CID 508 and 509.
---
 src/common/crypto.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/common/crypto.c b/src/common/crypto.c
index e79666f..dd85d14 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1055,7 +1055,7 @@ crypto_pk_public_hybrid_encrypt(crypto_pk_t *env,
     memset(buf, 0, pkeylen);
     tor_free(buf);
   }
-  if (cipher) crypto_cipher_free(cipher);
+  crypto_cipher_free(cipher);
   return -1;
 }
 
@@ -1112,7 +1112,7 @@ crypto_pk_private_hybrid_decrypt(crypto_pk_t *env,
  err:
   memset(buf,0,pkeylen);
   tor_free(buf);
-  if (cipher) crypto_cipher_free(cipher);
+  crypto_cipher_free(cipher);
   return -1;
 }
 





More information about the tor-commits mailing list