Skip to content

Commit b6cdf98

Browse files
committed
Merge remote-tracking branch 'public/pr/1721' into development-restricted
2 parents fed19be + 2239a86 commit b6cdf98

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

library/dhm.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,16 @@ void mbedtls_dhm_free( mbedtls_dhm_context *ctx )
452452
if( ctx == NULL )
453453
return;
454454

455-
mbedtls_mpi_free( &ctx->pX ); mbedtls_mpi_free( &ctx->Vf );
456-
mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->RP );
457-
mbedtls_mpi_free( &ctx->K ); mbedtls_mpi_free( &ctx->GY );
458-
mbedtls_mpi_free( &ctx->GX ); mbedtls_mpi_free( &ctx->X );
459-
mbedtls_mpi_free( &ctx->G ); mbedtls_mpi_free( &ctx->P );
455+
mbedtls_mpi_free( &ctx->pX );
456+
mbedtls_mpi_free( &ctx->Vf );
457+
mbedtls_mpi_free( &ctx->Vi );
458+
mbedtls_mpi_free( &ctx->RP );
459+
mbedtls_mpi_free( &ctx->K );
460+
mbedtls_mpi_free( &ctx->GY );
461+
mbedtls_mpi_free( &ctx->GX );
462+
mbedtls_mpi_free( &ctx->X );
463+
mbedtls_mpi_free( &ctx->G );
464+
mbedtls_mpi_free( &ctx->P );
460465

461466
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_dhm_context ) );
462467
}

library/pem.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,11 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
423423

424424
void mbedtls_pem_free( mbedtls_pem_context *ctx )
425425
{
426-
if( ctx->buf != NULL )
426+
if ( ctx->buf != NULL )
427+
{
427428
mbedtls_platform_zeroize( ctx->buf, ctx->buflen );
428-
mbedtls_free( ctx->buf );
429+
mbedtls_free( ctx->buf );
430+
}
429431
mbedtls_free( ctx->info );
430432

431433
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pem_context ) );

library/pk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ void mbedtls_pk_init( mbedtls_pk_context *ctx )
6666
*/
6767
void mbedtls_pk_free( mbedtls_pk_context *ctx )
6868
{
69-
if( ctx == NULL || ctx->pk_info == NULL )
69+
if( ctx == NULL )
7070
return;
7171

72-
ctx->pk_info->ctx_free_func( ctx->pk_ctx );
72+
if ( ctx->pk_info != NULL )
73+
ctx->pk_info->ctx_free_func( ctx->pk_ctx );
7374

7475
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pk_context ) );
7576
}

library/rsa.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,14 +2484,20 @@ void mbedtls_rsa_free( mbedtls_rsa_context *ctx )
24842484
if( ctx == NULL )
24852485
return;
24862486

2487-
mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->Vf );
2488-
mbedtls_mpi_free( &ctx->RN ); mbedtls_mpi_free( &ctx->D );
2489-
mbedtls_mpi_free( &ctx->Q ); mbedtls_mpi_free( &ctx->P );
2490-
mbedtls_mpi_free( &ctx->E ); mbedtls_mpi_free( &ctx->N );
2487+
mbedtls_mpi_free( &ctx->Vi );
2488+
mbedtls_mpi_free( &ctx->Vf );
2489+
mbedtls_mpi_free( &ctx->RN );
2490+
mbedtls_mpi_free( &ctx->D );
2491+
mbedtls_mpi_free( &ctx->Q );
2492+
mbedtls_mpi_free( &ctx->P );
2493+
mbedtls_mpi_free( &ctx->E );
2494+
mbedtls_mpi_free( &ctx->N );
24912495

24922496
#if !defined(MBEDTLS_RSA_NO_CRT)
2493-
mbedtls_mpi_free( &ctx->RQ ); mbedtls_mpi_free( &ctx->RP );
2494-
mbedtls_mpi_free( &ctx->QP ); mbedtls_mpi_free( &ctx->DQ );
2497+
mbedtls_mpi_free( &ctx->RQ );
2498+
mbedtls_mpi_free( &ctx->RP );
2499+
mbedtls_mpi_free( &ctx->QP );
2500+
mbedtls_mpi_free( &ctx->DQ );
24952501
mbedtls_mpi_free( &ctx->DP );
24962502
#endif /* MBEDTLS_RSA_NO_CRT */
24972503

0 commit comments

Comments
 (0)