Make bytes big enough in case n == 0

This commit is contained in:
Ramana Kumar 2022-11-26 22:14:21 +00:00
parent 73d5d2fb0b
commit b69104859f
No known key found for this signature in database
GPG Key ID: ED471C788B900433
1 changed files with 1 additions and 1 deletions

View File

@ -1098,7 +1098,7 @@ static C_KZG_RET compute_challenges(BLSFieldElement *out, BLSFieldElement r_powe
const size_t np = ni + n * BYTES_PER_BLOB;
const size_t nb = np + n * 48;
uint8_t* bytes = calloc(nb, sizeof(uint8_t));
uint8_t* bytes = calloc(nb + (n == 0), sizeof(uint8_t)); // need at least 1 byte more than ni for hash later
if (bytes == NULL) return C_KZG_MALLOC;
memcpy(bytes, FIAT_SHAMIR_PROTOCOL_DOMAIN, 16);