Make EVP_AEAD_CTX_free accept NULL.

This matches our other free functions.

Fixed: 473
Change-Id: Ie147995c2f5b429f78e95cfc9a08ed54181af94e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51005
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/cipher_extra/aead_test.cc b/crypto/cipher_extra/aead_test.cc
index 9e5dcee..6c6210d 100644
--- a/crypto/cipher_extra/aead_test.cc
+++ b/crypto/cipher_extra/aead_test.cc
@@ -1008,3 +1008,7 @@
         RunWycheproofTestCase(t, EVP_aead_xchacha20_poly1305());
       });
 }
+
+TEST(AEADTest, FreeNull) {
+  EVP_AEAD_CTX_free(nullptr);
+}
diff --git a/crypto/fipsmodule/cipher/aead.c b/crypto/fipsmodule/cipher/aead.c
index 8d2ad04..97f0b0d 100644
--- a/crypto/fipsmodule/cipher/aead.c
+++ b/crypto/fipsmodule/cipher/aead.c
@@ -51,6 +51,9 @@
 }
 
 void EVP_AEAD_CTX_free(EVP_AEAD_CTX *ctx) {
+  if (ctx == NULL) {
+    return;
+  }
   EVP_AEAD_CTX_cleanup(ctx);
   OPENSSL_free(ctx);
 }