[tor-commits] [tor/master] Remove needless check for a buffer that could not be NULL.

nickm at torproject.org nickm at torproject.org
Wed Apr 18 14:42:21 UTC 2012


commit 4db5a1e151a7aa69f2682854b021d1f9bb0f5caf
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Apr 18 10:38:39 2012 -0400

    Remove needless check for a buffer that could not be NULL.
    
    Fixes coverity CID 508: coverity scan doesn't like checking a
    variable for non-NULL after it has been definitely dereferenced.
    
    This should take us back down to zero coverity issues.
---
 src/common/crypto.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/common/crypto.c b/src/common/crypto.c
index dd85d14..e37b282 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1051,10 +1051,9 @@ crypto_pk_public_hybrid_encrypt(crypto_pk_t *env,
   tor_assert(outlen+symlen < INT_MAX);
   return (int)(outlen + symlen);
  err:
-  if (buf) {
-    memset(buf, 0, pkeylen);
-    tor_free(buf);
-  }
+
+  memset(buf, 0, pkeylen);
+  tor_free(buf);
   crypto_cipher_free(cipher);
   return -1;
 }



More information about the tor-commits mailing list