mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
Replace malloc with calloc
- platform layer currently broken (not adapted yet) - memmory_buffer_alloc too
This commit is contained in:
parent
065122cfe9
commit
7551cb9ee9
31 changed files with 122 additions and 131 deletions
|
|
@ -41,7 +41,7 @@
|
|||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_malloc malloc
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
|
|||
if( ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER )
|
||||
return( MBEDTLS_ERR_PEM_INVALID_DATA + ret );
|
||||
|
||||
if( ( buf = mbedtls_malloc( len ) ) == NULL )
|
||||
if( ( buf = mbedtls_calloc( 1, len ) ) == NULL )
|
||||
return( MBEDTLS_ERR_PEM_MALLOC_FAILED );
|
||||
|
||||
if( ( ret = mbedtls_base64_decode( buf, &len, s1, s2 - s1 ) ) != 0 )
|
||||
|
|
@ -407,7 +407,7 @@ int mbedtls_pem_write_buffer( const char *header, const char *footer,
|
|||
return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL );
|
||||
}
|
||||
|
||||
if( ( encode_buf = mbedtls_malloc( use_len ) ) == NULL )
|
||||
if( ( encode_buf = mbedtls_calloc( 1, use_len ) ) == NULL )
|
||||
return( MBEDTLS_ERR_PEM_MALLOC_FAILED );
|
||||
|
||||
if( ( ret = mbedtls_base64_encode( encode_buf, &use_len, der_data,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue