BUG FIX: seemingly identical obiblobs would have different hash values

because of the padding added by the compiler. Fixed by using calloc
instead of malloc for obiblob memory allocation.
This commit is contained in:
Celine Mercier
2017-08-20 17:25:15 +02:00
parent 6afdc9fb5f
commit 9744a48a67

View File

@ -32,7 +32,7 @@ Obi_blob_p obi_blob(byte_t* encoded_value, uint8_t element_size, int32_t length_
Obi_blob_p blob; Obi_blob_p blob;
// Allocate the memory for the blob structure // Allocate the memory for the blob structure
blob = (Obi_blob_p) malloc(sizeof(Obi_blob_t) + length_encoded_value); blob = (Obi_blob_p) calloc(sizeof(Obi_blob_t) + length_encoded_value, sizeof(byte_t));
if (blob == NULL) if (blob == NULL)
{ {
obi_set_errno(OBI_MALLOC_ERROR); obi_set_errno(OBI_MALLOC_ERROR);