speed: Fix memory leak

Free the signature stack after iterating over all found signatures.
Free the kem and signature stacks at the end of speed_main() if not
NULL.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21491)
This commit is contained in:
Ingo Franzki 2023-07-19 14:59:16 +02:00 committed by Pauli
parent 51a7066e20
commit cc7e2b20de
1 changed files with 6 additions and 0 deletions

View File

@ -2040,6 +2040,8 @@ int speed_main(int argc, char **argv)
sigs_algname[sigs_algs_len++] = OPENSSL_strdup(sig_name);
}
}
sk_EVP_SIGNATURE_pop_free(sig_stack, EVP_SIGNATURE_free);
sig_stack = NULL;
/* Remaining arguments are algorithms. */
argc = opt_num_rest();
@ -4227,8 +4229,12 @@ skip_hmac:
OPENSSL_free(evp_cmac_name);
for (k = 0; k < kems_algs_len; k++)
OPENSSL_free(kems_algname[k]);
if (kem_stack != NULL)
sk_EVP_KEM_pop_free(kem_stack, EVP_KEM_free);
for (k = 0; k < sigs_algs_len; k++)
OPENSSL_free(sigs_algname[k]);
if (sig_stack != NULL)
sk_EVP_SIGNATURE_pop_free(sig_stack, EVP_SIGNATURE_free);
if (async_jobs > 0) {
for (i = 0; i < loopargs_len; i++)