]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Remove a couple redundant NULL-checks before crypto_cipher_free
authorNick Mathewson <nickm@torproject.org>
Fri, 30 Mar 2012 14:16:58 +0000 (10:16 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 30 Mar 2012 14:16:58 +0000 (10:16 -0400)
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

index e79666f9555fecc5790bace01be274d7943a8132..dd85d147192ee3d9c2b8e52d250cd74572c18e09 100644 (file)
@@ -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;
 }