commit | d1593f54c9e12ae4dd3dfae67a1e0c2596234701 | [log] [tgz] |
---|---|---|
author | David Benjamin <davidben@google.com> | Mon Jan 17 11:17:09 2022 -0500 |
committer | Boringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> | Tue Jan 18 16:42:22 2022 +0000 |
tree | 94002206e06f1f2f1c75b3d98f3835764efd837f | |
parent | ec476ef0441f32fbcab558127412461617516336 [diff] |
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); }