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 "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_malloc malloc
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
@ -134,7 +134,7 @@ static int rsa_check_pair_wrap( const void *pub, const void *prv )
|
||||
|
||||
static void *rsa_alloc_wrap( void )
|
||||
{
|
||||
void *ctx = mbedtls_malloc( sizeof( mbedtls_rsa_context ) );
|
||||
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_context ) );
|
||||
|
||||
if( ctx != NULL )
|
||||
mbedtls_rsa_init( (mbedtls_rsa_context *) ctx, 0, 0 );
|
||||
@ -250,7 +250,7 @@ static int eckey_check_pair( const void *pub, const void *prv )
|
||||
|
||||
static void *eckey_alloc_wrap( void )
|
||||
{
|
||||
void *ctx = mbedtls_malloc( sizeof( mbedtls_ecp_keypair ) );
|
||||
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecp_keypair ) );
|
||||
|
||||
if( ctx != NULL )
|
||||
mbedtls_ecp_keypair_init( ctx );
|
||||
@ -349,7 +349,7 @@ static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
|
||||
|
||||
static void *ecdsa_alloc_wrap( void )
|
||||
{
|
||||
void *ctx = mbedtls_malloc( sizeof( mbedtls_ecdsa_context ) );
|
||||
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) );
|
||||
|
||||
if( ctx != NULL )
|
||||
mbedtls_ecdsa_init( (mbedtls_ecdsa_context *) ctx );
|
||||
@ -458,7 +458,7 @@ static int rsa_alt_check_pair( const void *pub, const void *prv )
|
||||
|
||||
static void *rsa_alt_alloc_wrap( void )
|
||||
{
|
||||
void *ctx = mbedtls_malloc( sizeof( mbedtls_rsa_alt_context ) );
|
||||
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_alt_context ) );
|
||||
|
||||
if( ctx != NULL )
|
||||
memset( ctx, 0, sizeof( mbedtls_rsa_alt_context ) );
|
||||
|
Reference in New Issue
Block a user