Skip to content

Commit 30f110b

Browse files
committed
test: free ECC curve spec cache at unit.test teardown to plug still-reachable leak
1 parent 2cdbd25 commit 30f110b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,6 +3348,14 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
33483348
wc_ecc_fp_free();
33493349
#endif
33503350

3351+
/* Free the global ECC curve spec cache. Independent of FP_ECC: enabled
3352+
* by default in async builds (see settings.h) and is not cleaned up by
3353+
* wc_ecc_fp_free(). Without this, valgrind --leak-check=full flags the
3354+
* cached curve specs (and their wc_bigint copies) as still-reachable. */
3355+
#if defined(HAVE_ECC) && defined(ECC_CACHE_CURVE)
3356+
wc_ecc_curve_cache_free();
3357+
#endif
3358+
33513359
#ifdef TEST_ALWAYS_RUN_TO_END
33523360
if (last_failed_test_ret != 0)
33533361
ret = last_failed_test_ret;

0 commit comments

Comments
 (0)