diff --git a/library/entropy_poll.c b/library/entropy_poll.c index 25a27bef3e..01bd58efcb 100644 --- a/library/entropy_poll.c +++ b/library/entropy_poll.c @@ -61,7 +61,10 @@ int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len } if( CryptGenRandom( provider, (DWORD) len, output ) == FALSE ) + { + CryptReleaseContext( provider, 0 ); return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); + } CryptReleaseContext( provider, 0 ); *olen = len;