Skip to content

Commit 823839b

Browse files
Eric Wonggitster
authored andcommitted
sha256/gcrypt: die on gcry_md_open failures
`gcry_md_open' allocates memory and must (like all allocation functions) be checked for failure. Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b608f3 commit 823839b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sha256/gcrypt.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ typedef gcry_md_hd_t gcrypt_SHA256_CTX;
99

1010
static inline void gcrypt_SHA256_Init(gcrypt_SHA256_CTX *ctx)
1111
{
12-
gcry_md_open(ctx, GCRY_MD_SHA256, 0);
12+
gcry_error_t err = gcry_md_open(ctx, GCRY_MD_SHA256, 0);
13+
if (err)
14+
die("gcry_md_open: %s", gcry_strerror(err));
1315
}
1416

1517
static inline void gcrypt_SHA256_Update(gcrypt_SHA256_CTX *ctx, const void *data, size_t len)

0 commit comments

Comments
 (0)