Replace malloc with calloc
- platform layer currently broken (not adapted yet)
- memmory_buffer_alloc too
diff --git a/library/bignum.c b/library/bignum.c
index 9776092..b65858d 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -46,7 +46,7 @@
#include <stdio.h>
#include <stdlib.h>
#define mbedtls_printf printf
-#define mbedtls_malloc malloc
+#define mbedtls_calloc calloc
#define mbedtls_free free
#endif
@@ -109,11 +109,9 @@
if( X->n < nblimbs )
{
- if( ( p = mbedtls_malloc( nblimbs * ciL ) ) == NULL )
+ if( ( p = mbedtls_calloc( nblimbs, ciL ) ) == NULL )
return( MBEDTLS_ERR_MPI_MALLOC_FAILED );
- memset( p, 0, nblimbs * ciL );
-
if( X->p != NULL )
{
memcpy( p, X->p, X->n * ciL );
@@ -149,11 +147,9 @@
if( i < nblimbs )
i = nblimbs;
- if( ( p = mbedtls_malloc( i * ciL ) ) == NULL )
+ if( ( p = mbedtls_calloc( i, ciL ) ) == NULL )
return( MBEDTLS_ERR_MPI_MALLOC_FAILED );
- memset( p, 0, i * ciL );
-
if( X->p != NULL )
{
memcpy( p, X->p, i * ciL );