mirror of https://github.com/wolfSSL/wolfssl
Fix memory leak in api.c
When testing wc_ecc_import_raw(), the mp_int's in the ecc object are initialized. For small math, this throws away the allocated buffer. Must free the object before importing.
This commit is contained in:
parent
72d1352bd6
commit
7bb2a69161
|
@ -19602,6 +19602,9 @@ static int test_wc_ecc_import_raw(void)
|
|||
}
|
||||
#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
|
||||
if (ret == BAD_FUNC_ARG) {
|
||||
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH)
|
||||
wc_ecc_free(&key);
|
||||
#endif
|
||||
ret = wc_ecc_import_raw(&key, kNullStr, kNullStr, kNullStr, curveName);
|
||||
if (ret == ECC_INF_E)
|
||||
ret = BAD_FUNC_ARG; /* This is expected by other tests */
|
||||
|
@ -19609,9 +19612,15 @@ static int test_wc_ecc_import_raw(void)
|
|||
#endif
|
||||
#if !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS)
|
||||
if (ret == BAD_FUNC_ARG) {
|
||||
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH)
|
||||
wc_ecc_free(&key);
|
||||
#endif
|
||||
ret = wc_ecc_import_raw(&key, "0", qy, d, curveName);
|
||||
}
|
||||
if (ret == BAD_FUNC_ARG) {
|
||||
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH)
|
||||
wc_ecc_free(&key);
|
||||
#endif
|
||||
ret = wc_ecc_import_raw(&key, qx, "0", d, curveName);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue