Replace malloc with calloc
- platform layer currently broken (not adapted yet)
- memmory_buffer_alloc too
diff --git a/library/x509_crt.c b/library/x509_crt.c
index 11eb7cf..849ea7b 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -53,7 +53,7 @@
#else
#include <stdlib.h>
#define mbedtls_free free
-#define mbedtls_malloc malloc
+#define mbedtls_calloc calloc
#define mbedtls_snprintf snprintf
#endif
@@ -359,7 +359,7 @@
if( cur->next != NULL )
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS );
- cur->next = mbedtls_malloc( sizeof( mbedtls_asn1_sequence ) );
+ cur->next = mbedtls_calloc( 1, sizeof( mbedtls_asn1_sequence ) );
if( cur->next == NULL )
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
@@ -553,7 +553,7 @@
if( crt == NULL || buf == NULL )
return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
- p = mbedtls_malloc( len = buflen );
+ p = mbedtls_calloc( 1, len = buflen );
if( p == NULL )
return( MBEDTLS_ERR_X509_MALLOC_FAILED );
@@ -808,7 +808,7 @@
*/
if( crt->version != 0 && crt->next == NULL )
{
- crt->next = mbedtls_malloc( sizeof( mbedtls_x509_crt ) );
+ crt->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) );
if( crt->next == NULL )
return( MBEDTLS_ERR_X509_MALLOC_FAILED );