mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
ECC-FP Cache Memory Leak
Each test case for ECC should be cleaning up the FP cache if it uses the cache. Only a couple cases were getting freed.
This commit is contained in:
55
tests/api.c
55
tests/api.c
@ -2480,6 +2480,11 @@ done:
|
||||
fdCloseSession(Task_self());
|
||||
#endif
|
||||
|
||||
#if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \
|
||||
&& defined(HAVE_THREAD_LS)
|
||||
wc_ecc_fp_free(); /* free per thread cache */
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -14195,6 +14200,10 @@ static int test_wc_ecc_make_key (void)
|
||||
ret = WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
#endif
|
||||
|
||||
@ -14277,6 +14286,10 @@ static int test_wc_ecc_check_key (void)
|
||||
}
|
||||
wc_ecc_free(&key);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -14454,6 +14467,11 @@ static int test_wc_ecc_signVerify_hash (void)
|
||||
ret = WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
wc_ecc_free(&key);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -14522,6 +14540,10 @@ static int test_wc_ecc_shared_secret (void)
|
||||
wc_ecc_free(&key);
|
||||
wc_ecc_free(&pubKey);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -14583,6 +14605,10 @@ static int test_wc_ecc_export_x963 (void)
|
||||
}
|
||||
wc_ecc_free(&key);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -14682,6 +14708,10 @@ static int test_wc_ecc_export_x963_ex (void)
|
||||
}
|
||||
wc_ecc_free(&key);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -14746,6 +14776,10 @@ static int test_wc_ecc_import_x963 (void)
|
||||
wc_ecc_free(&key);
|
||||
wc_ecc_free(&pubKey);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -14817,6 +14851,10 @@ static int ecc_import_private_key (void)
|
||||
wc_ecc_free(&key);
|
||||
wc_ecc_free(&keyImp);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -14874,6 +14912,10 @@ static int test_wc_ecc_export_private_only (void)
|
||||
}
|
||||
wc_ecc_free(&key);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -15684,6 +15726,10 @@ static int test_wc_ecc_shared_secret_ssh (void)
|
||||
wc_ecc_free(&key);
|
||||
wc_ecc_free(&key2);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@ -15893,6 +15939,9 @@ static int test_wc_ecc_mulmod (void)
|
||||
wc_ecc_free(&key2);
|
||||
wc_ecc_free(&key3);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_ECC && !WOLFSSL_ATECC508A */
|
||||
return ret;
|
||||
@ -15948,6 +15997,9 @@ static int test_wc_ecc_is_valid_idx (void)
|
||||
ret = WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
wc_ecc_free(&key);
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
@ -24199,6 +24251,9 @@ static void test_wolfSSL_PEM_write_bio_PKCS7(void)
|
||||
if (cert_buf)
|
||||
free(cert_buf);
|
||||
|
||||
#ifdef FP_ECC
|
||||
wc_ecc_fp_free();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user