Fix memory leak in unit test, fix for loop syntax.

This commit is contained in:
Kareem
2025-08-21 16:33:57 -07:00
parent b53db94f1e
commit 077beaecd8
2 changed files with 4 additions and 3 deletions

View File

@@ -472,6 +472,7 @@ int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx)
int added = 0;
int i = 0;
int numInterAdd = 0;
int numFailedCerts = 0;
int depth = 0;
int origDepth = 0;
WOLFSSL_X509 *issuer = NULL;
@@ -627,8 +628,8 @@ int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx)
exit:
/* Copy back failed certs if verification failed. */
if (ret != WOLFSSL_SUCCESS) {
for (int cnt = 0, total = wolfSSL_sk_X509_num(failedCerts);
cnt < total; cnt++)
numFailedCerts = wolfSSL_sk_X509_num(failedCerts);
for (i = 0; i < numFailedCerts; i++)
{
wolfSSL_sk_X509_push(certs, wolfSSL_sk_X509_pop(failedCerts));
}

View File

@@ -20390,9 +20390,9 @@ static int test_wolfSSL_X509_STORE_CTX_ex12(void)
ExpectNotNull(ctx = X509_STORE_CTX_new());
ExpectIntEQ(X509_STORE_CTX_init(ctx, store, badAkiX509, NULL), 1);
ExpectIntEQ(X509_verify_cert(ctx), 0);
X509_STORE_CTX_cleanup(ctx);
ExpectIntEQ(X509_STORE_add_cert(store, badAkiX509), 1);
ExpectNotNull(ctx = X509_STORE_CTX_new());
ExpectNotNull(ca1X509 = test_wolfSSL_X509_STORE_CTX_ex_helper(intCA1ECCFile));
ExpectIntEQ(X509_STORE_CTX_init(ctx, store, ca1X509, NULL), 1);
ExpectIntEQ(X509_verify_cert(ctx), 1);