From 73d5d2fb0b87f1d4f01d6da968d8b2fe73620245 Mon Sep 17 00:00:00 2001 From: Ramana Kumar Date: Fri, 25 Nov 2022 22:07:34 +0000 Subject: [PATCH] Statically allocate hash_output --- src/c_kzg_4844.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/c_kzg_4844.c b/src/c_kzg_4844.c index b8cdcd1..ebf207b 100644 --- a/src/c_kzg_4844.c +++ b/src/c_kzg_4844.c @@ -1112,8 +1112,7 @@ static C_KZG_RET compute_challenges(BLSFieldElement *out, BLSFieldElement r_powe for (i = 0; i < n; i++) bytes_from_g1(&bytes[np + i * 48], &comms[i]); - uint8_t* hash_output = calloc(32, sizeof(uint8_t)); - if (hash_output == NULL) { free(bytes); return C_KZG_MALLOC; } + uint8_t hash_output[32] = {0}; hash(hash_output, bytes, nb); memcpy(bytes, hash_output, 32); bytes[32] = 0x0; @@ -1128,7 +1127,6 @@ static C_KZG_RET compute_challenges(BLSFieldElement *out, BLSFieldElement r_powe hash(hash_output, bytes, 33); bytes_to_bls_field(out, hash_output); - free(hash_output); free(bytes); return C_KZG_OK; }