Skip to content

Commit ebd8414

Browse files
committed
Move bio in gate so no need for null check
1 parent 9e90eb8 commit ebd8414

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/wp_dh_kmgmt.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,10 +2529,9 @@ static int wp_dh_encode(wp_DhEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
25292529
OSSL_PASSPHRASE_CALLBACK *pwCb, void *pwCbArg)
25302530
{
25312531
int ok = 1;
2532-
BIO* out = NULL;
25332532
#if (LIBWOLFSSL_VERSION_HEX >= 0x05000000 && defined(WOLFSSL_DH_EXTRA))
25342533
int rc;
2535-
out = wp_corebio_get_bio(ctx->provCtx, cBio);
2534+
BIO* out = wp_corebio_get_bio(ctx->provCtx, cBio);
25362535
unsigned char* keyData = NULL;
25372536
size_t keyLen;
25382537
unsigned char* derData = NULL;
@@ -2656,6 +2655,8 @@ static int wp_dh_encode(wp_DhEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
26562655
OPENSSL_free(pemData);
26572656
}
26582657
OPENSSL_free(cipherInfo);
2658+
2659+
BIO_free(out);
26592660
#else
26602661
(void)ctx;
26612662
(void)cBio;
@@ -2666,9 +2667,6 @@ static int wp_dh_encode(wp_DhEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
26662667
(void)pwCbArg;
26672668
#endif
26682669

2669-
if (out != NULL) {
2670-
BIO_free(out);
2671-
}
26722670
WOLFPROV_LEAVE(WP_LOG_KE, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
26732671
return ok;
26742672
}

0 commit comments

Comments
 (0)