$OpenBSD: patch-src_mongo_crypto_sha1_block_openssl_cpp,v 1.1 2021/11/27 14:17:02 tb Exp $

Part of
https://github.com/mongodb/mongo/commit/62ecb7bc5294461244bc07995ac6d113d582bc84

Index: src/mongo/crypto/sha1_block_openssl.cpp
--- src/mongo/crypto/sha1_block_openssl.cpp.orig
+++ src/mongo/crypto/sha1_block_openssl.cpp
@@ -70,14 +70,12 @@ namespace mongo {
 SHA1Block SHA1Block::computeHash(const uint8_t* input, size_t inputLen) {
     HashType output;
 
-    EVP_MD_CTX digestCtx;
-    EVP_MD_CTX_init(&digestCtx);
-    ON_BLOCK_EXIT(EVP_MD_CTX_cleanup, &digestCtx);
-
+    std::unique_ptr<EVP_MD_CTX, decltype(&EVP_MD_CTX_free)> digestCtx(EVP_MD_CTX_new(),
+                                                                      EVP_MD_CTX_free);
     fassert(40379,
-            EVP_DigestInit_ex(&digestCtx, EVP_sha1(), NULL) == 1 &&
-                EVP_DigestUpdate(&digestCtx, input, inputLen) == 1 &&
-                EVP_DigestFinal_ex(&digestCtx, output.data(), NULL) == 1);
+            EVP_DigestInit_ex(digestCtx.get(), EVP_sha1(), NULL) == 1 &&
+                EVP_DigestUpdate(digestCtx.get(), input, inputLen) == 1 &&
+                EVP_DigestFinal_ex(digestCtx.get(), output.data(), NULL) == 1);
     return SHA1Block(output);
 }
 
