From d9ca94a677ddfe77c39aa281875164ae437fa463 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Thu, 25 Jul 2013 11:25:09 +0200 Subject: [PATCH] Updated merged pk.c and x509parse.c changes with new memory allocation functions --- library/pk.c | 11 +++++++++-- library/x509parse.c | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/library/pk.c b/library/pk.c index 78ff5e97c..3755fbcfe 100644 --- a/library/pk.c +++ b/library/pk.c @@ -37,6 +37,13 @@ #include "polarssl/ecdsa.h" #endif +#if defined(POLARSSL_MEMORY_C) +#include "polarssl/memory.h" +#else +#define polarssl_malloc malloc +#define polarssl_free free +#endif + #include /* @@ -80,7 +87,7 @@ void pk_free( pk_context *ctx ) } if( ! ctx->dont_free ) - free( ctx->data ); + polarssl_free( ctx->data ); ctx->type = POLARSSL_PK_NONE; ctx->data = NULL; @@ -116,7 +123,7 @@ int pk_set_type( pk_context *ctx, pk_type_t type ) #endif return( POLARSSL_ERR_PK_TYPE_MISMATCH ); - if( ( ctx->data = malloc( size ) ) == NULL ) + if( ( ctx->data = polarssl_malloc( size ) ) == NULL ) return( POLARSSL_ERR_PK_MALLOC_FAILED ); memset( ctx->data, 0, size ); diff --git a/library/x509parse.c b/library/x509parse.c index a11c06488..ace7fe8b0 100644 --- a/library/x509parse.c +++ b/library/x509parse.c @@ -2091,7 +2091,7 @@ int x509parse_keyfile( pk_context *ctx, (const unsigned char *) pwd, strlen( pwd ) ); memset( buf, 0, n + 1 ); - free( buf ); + polarssl_free( buf ); return( ret ); } @@ -2111,7 +2111,7 @@ int x509parse_public_keyfile( pk_context *ctx, const char *path ) ret = x509parse_public_key( ctx, buf, n ); memset( buf, 0, n + 1 ); - free( buf ); + polarssl_free( buf ); return( ret ); }