diff options
author | Eric Wong <e@80x24.org> | 2023-07-31 14:08:07 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-07-31 17:57:15 +0200 |
commit | 8b608f3fb84388bb1b6da70feb62e20a19390cb6 (patch) | |
tree | 3457574a965687827c816b1f8429d4f23d698b56 /sha256 | |
parent | sha256/gcrypt: fix build with SANITIZE=leak (diff) | |
download | git-8b608f3fb84388bb1b6da70feb62e20a19390cb6.tar.xz git-8b608f3fb84388bb1b6da70feb62e20a19390cb6.zip |
sha256/gcrypt: fix memory leak with SHA-256 repos
`gcry_md_open' needs to be paired with `gcry_md_close' to ensure
resources are released. Since our internal APIs don't have
separate close/release callbacks, sticking it into the finalization
callback seems appropriate.
Building with SANITIZE=leak and running `git fsck' on a SHA-256
repository no longer reports leaks.
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha256')
-rw-r--r-- | sha256/gcrypt.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sha256/gcrypt.h b/sha256/gcrypt.h index 68cf6b6a54..1d06a778af 100644 --- a/sha256/gcrypt.h +++ b/sha256/gcrypt.h @@ -20,6 +20,7 @@ static inline void gcrypt_SHA256_Update(gcrypt_SHA256_CTX *ctx, const void *data static inline void gcrypt_SHA256_Final(unsigned char *digest, gcrypt_SHA256_CTX *ctx) { memcpy(digest, gcry_md_read(*ctx, GCRY_MD_SHA256), SHA256_DIGEST_SIZE); + gcry_md_close(*ctx); } static inline void gcrypt_SHA256_Clone(gcrypt_SHA256_CTX *dst, const gcrypt_SHA256_CTX *src) |