mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Replace malloc with calloc
- platform layer currently broken (not adapted yet) - memmory_buffer_alloc too
This commit is contained in:
@ -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 @@ int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs )
|
||||
|
||||
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 @@ int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs )
|
||||
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 );
|
||||
|
Reference in New Issue
Block a user