From: Dr. Stephen Henson Date: Thu, 12 Feb 2015 16:34:10 +0000 (+0000) Subject: Add leak detection, fix leaks. X-Git-Tag: OpenSSL_1_1_0-pre1~1635 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d5ec8efc70d3f9197dd6965d959de7dcda784459;p=oweals%2Fopenssl.git Add leak detection, fix leaks. Reviewed-by: Richard Levitte --- diff --git a/crypto/evp/evp_test.c b/crypto/evp/evp_test.c index e3a1693c61..78e8b7020e 100644 --- a/crypto/evp/evp_test.c +++ b/crypto/evp/evp_test.c @@ -298,11 +298,8 @@ static int setup_test(struct evp_test *t, const struct evp_test_method *tmeth) } ERR_clear_error(); t->meth->cleanup(t); - /* If new test type free old data */ - if (tmeth != t->meth && t->data) { - OPENSSL_free(t->data); - t->data = NULL; - } + OPENSSL_free(t->data); + t->data = NULL; if (t->expected_err) { OPENSSL_free(t->expected_err); t->expected_err = NULL; @@ -323,9 +320,13 @@ static EVP_PKEY *find_key(const char *name, struct key_list *lst) static void free_key_list(struct key_list *lst) { - for (; lst; lst = lst->next) { + while (lst != NULL) { + struct key_list *ltmp; EVP_PKEY_free(lst->key); OPENSSL_free(lst->name); + ltmp = lst->next; + OPENSSL_free(lst); + lst = ltmp; } } @@ -449,6 +450,8 @@ int main(int argc, char **argv) return 1; } + CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); + ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); t.meth = NULL; @@ -477,6 +480,11 @@ int main(int argc, char **argv) free_key_list(t.public); free_key_list(t.private); fclose(in); + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_thread_state(NULL); + ERR_free_strings(); + CRYPTO_mem_leaks_fp(stderr); if (t.errors) return 1; return 0;