Move existence check for pk/frame to mbedtls_x509_crt_provide_xxx()
diff --git a/library/x509_crt.c b/library/x509_crt.c
index 91b29b6..9004be4 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -165,6 +165,9 @@
mbedtls_x509_crt_cache *cache = crt->cache;
mbedtls_x509_crt_frame *frame;
+ if( cache->frame != NULL )
+ return( 0 );
+
frame = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt_frame ) );
if( frame == NULL )
return( MBEDTLS_ERR_X509_ALLOC_FAILED );
@@ -214,6 +217,9 @@
mbedtls_x509_crt_cache *cache = crt->cache;
mbedtls_pk_context *pk;
+ if( cache->pk != NULL )
+ return( 0 );
+
pk = mbedtls_calloc( 1, sizeof( mbedtls_pk_context ) );
if( pk == NULL )
return( MBEDTLS_ERR_X509_ALLOC_FAILED );
@@ -1459,7 +1465,7 @@
if( ret != 0 )
goto exit;
- frame = mbedtls_x509_crt_cache_get_frame( crt->cache );
+ frame = crt->cache->frame;
#else /* MBEDTLS_X509_ON_DEMAND_PARSING */