Import "Remove some code for a contributor that we cannot find" from upstream OpenSSL

This imports
https://github.com/openssl/openssl/commit/320a81277e402f393289ae7229b2320324321fb1
from upstream OpenSSL.

This causes the following free functions to no longer check for NULL:

* BIO_CONNECT_free
* BUF_MEM_free
* BN_CTX_free
* BN_RECP_CTX_free
* BN_MONT_CTX_free
* BN_BLINDING_free
* X509_STORE_free
* SSL_SESSION_free

(It also causes tls_free to no longer check for NULL, but that check was
unnecessary.)

Bug: 364634028
Change-Id: Ia625039a0a22b0bf368c39d6b8090ca15955f8e4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/74828
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/bio/connect.cc b/crypto/bio/connect.cc
index b144339..c97f320 100644
--- a/crypto/bio/connect.cc
+++ b/crypto/bio/connect.cc
@@ -260,10 +260,6 @@
 }
 
 static void BIO_CONNECT_free(BIO_CONNECT *c) {
-  if (c == NULL) {
-    return;
-  }
-
   OPENSSL_free(c->param_hostname);
   OPENSSL_free(c->param_port);
   OPENSSL_free(c);
diff --git a/crypto/buf/buf.cc b/crypto/buf/buf.cc
index c2403fe..0010260 100644
--- a/crypto/buf/buf.cc
+++ b/crypto/buf/buf.cc
@@ -22,10 +22,6 @@
 }
 
 void BUF_MEM_free(BUF_MEM *buf) {
-  if (buf == NULL) {
-    return;
-  }
-
   OPENSSL_free(buf->data);
   OPENSSL_free(buf);
 }
diff --git a/crypto/fipsmodule/bn/ctx.cc.inc b/crypto/fipsmodule/bn/ctx.cc.inc
index 110bd97..7d012bb 100644
--- a/crypto/fipsmodule/bn/ctx.cc.inc
+++ b/crypto/fipsmodule/bn/ctx.cc.inc
@@ -76,10 +76,6 @@
 }
 
 void BN_CTX_free(BN_CTX *ctx) {
-  if (ctx == NULL) {
-    return;
-  }
-
   // All |BN_CTX_start| calls must be matched with |BN_CTX_end|, otherwise the
   // function may use more memory than expected, potentially without bound if
   // done in a loop. Assert that all |BIGNUM|s have been released.
diff --git a/crypto/fipsmodule/bn/exponentiation.cc.inc b/crypto/fipsmodule/bn/exponentiation.cc.inc
index 328fd07..df19716 100644
--- a/crypto/fipsmodule/bn/exponentiation.cc.inc
+++ b/crypto/fipsmodule/bn/exponentiation.cc.inc
@@ -136,10 +136,6 @@
 }
 
 static void BN_RECP_CTX_free(BN_RECP_CTX *recp) {
-  if (recp == NULL) {
-    return;
-  }
-
   BN_free(&recp->N);
   BN_free(&recp->Nr);
 }
diff --git a/crypto/fipsmodule/bn/montgomery.cc.inc b/crypto/fipsmodule/bn/montgomery.cc.inc
index 135a06e..22927ee 100644
--- a/crypto/fipsmodule/bn/montgomery.cc.inc
+++ b/crypto/fipsmodule/bn/montgomery.cc.inc
@@ -45,10 +45,6 @@
 }
 
 void BN_MONT_CTX_free(BN_MONT_CTX *mont) {
-  if (mont == NULL) {
-    return;
-  }
-
   bn_mont_ctx_cleanup(mont);
   OPENSSL_free(mont);
 }
diff --git a/crypto/fipsmodule/rsa/blinding.cc.inc b/crypto/fipsmodule/rsa/blinding.cc.inc
index 68fa59c..628f1ce 100644
--- a/crypto/fipsmodule/rsa/blinding.cc.inc
+++ b/crypto/fipsmodule/rsa/blinding.cc.inc
@@ -58,10 +58,6 @@
 }
 
 void BN_BLINDING_free(BN_BLINDING *r) {
-  if (r == NULL) {
-    return;
-  }
-
   BN_free(r->A);
   BN_free(r->Ai);
   OPENSSL_free(r);
diff --git a/crypto/x509/x509_lu.cc b/crypto/x509/x509_lu.cc
index eb3acb1..373015b 100644
--- a/crypto/x509/x509_lu.cc
+++ b/crypto/x509/x509_lu.cc
@@ -130,10 +130,6 @@
 }
 
 void X509_STORE_free(X509_STORE *vfy) {
-  if (vfy == NULL) {
-    return;
-  }
-
   if (!CRYPTO_refcount_dec_and_test_zero(&vfy->references)) {
     return;
   }
diff --git a/include/openssl/base.h b/include/openssl/base.h
index 1f9e70e..21afad8 100644
--- a/include/openssl/base.h
+++ b/include/openssl/base.h
@@ -18,6 +18,18 @@
 // * https://github.com/openssl/openssl/commit/86ba26c80a49aee3c588d286d91eb3843529f7e2
 // * https://github.com/openssl/openssl/commit/60eba30f60de55e3c782469fa555eede82606099
 // * https://github.com/openssl/openssl/commit/a2371fa93365cc0bc0e46b9d65f3a47a074b1c30
+//
+// Also after importing
+// https://github.com/openssl/openssl/commit/e6e9170d6e28038768895e1af18e3aad8093bf4b
+// to make the following functions accept a NULL parameter:
+// * BIO_CONNECT_free
+// * BUF_MEM_free
+// * BN_CTX_free
+// * BN_RECP_CTX_free
+// * BN_MONT_CTX_free
+// * BN_BLINDING_free
+// * X509_STORE_free
+// * SSL_SESSION_free
 #error "Do not build BoringSSL at this revision"
 
 #include <stddef.h>
diff --git a/ssl/s3_lib.cc b/ssl/s3_lib.cc
index 41e9c73..e77ee3f 100644
--- a/ssl/s3_lib.cc
+++ b/ssl/s3_lib.cc
@@ -72,7 +72,7 @@
 }
 
 void tls_free(SSL *ssl) {
-  if (ssl == NULL || ssl->s3 == NULL) {
+  if (ssl->s3 == NULL) {
     return;
   }
 
diff --git a/ssl/ssl_session.cc b/ssl/ssl_session.cc
index 02d50cc..cf57365 100644
--- a/ssl/ssl_session.cc
+++ b/ssl/ssl_session.cc
@@ -830,9 +830,7 @@
 }
 
 void SSL_SESSION_free(SSL_SESSION *session) {
-  if (session != nullptr) {
-    session->DecRefInternal();
-  }
+  session->DecRefInternal();
 }
 
 const uint8_t *SSL_SESSION_get_id(const SSL_SESSION *session,