From: Dr. Stephen Henson Date: Thu, 14 Jan 2016 22:00:03 +0000 (+0000) Subject: If memory debugging enabled return error on leaks. X-Git-Tag: OpenSSL_1_1_0-pre3~254 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=541e9565bb5b860e9e0b5faeb5d474deeaef743b;p=oweals%2Fopenssl.git If memory debugging enabled return error on leaks. Reviewed-by: Rich Salz --- diff --git a/apps/openssl.c b/apps/openssl.c index 37f71a94d6..b8da88a224 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -429,7 +429,8 @@ int main(int argc, char *argv[]) BIO_free_all(bio_out); apps_shutdown(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(bio_err); + if (CRYPTO_mem_leaks(bio_err) <= 0) + ret = 1; #endif BIO_free(bio_err); EXIT(ret); diff --git a/test/clienthellotest.c b/test/clienthellotest.c index 66fc27f48b..d9ae758987 100644 --- a/test/clienthellotest.c +++ b/test/clienthellotest.c @@ -217,7 +217,8 @@ int main(int argc, char *argv[]) EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(err); + if (CRYPTO_mem_leaks(err) <= 0) + testresult = 0; #endif BIO_free(err); diff --git a/test/danetest.c b/test/danetest.c index 636f629617..5c4a785c00 100644 --- a/test/danetest.c +++ b/test/danetest.c @@ -526,7 +526,8 @@ end: ERR_remove_thread_state(NULL); EVP_cleanup(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(bio_err); + if (CRYPTO_mem_leaks(bio_err) <= 0) + ret = 1; #endif BIO_free(bio_err); EXIT(ret); diff --git a/test/dsatest.c b/test/dsatest.c index 426e443bbc..f36b4494d0 100644 --- a/test/dsatest.c +++ b/test/dsatest.c @@ -215,7 +215,8 @@ int main(int argc, char **argv) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(bio_err); + if (CRYPTO_mem_leaks(bio_err) <= 0) + ret = 0; #endif BIO_free(bio_err); bio_err = NULL; diff --git a/test/ecdhtest.c b/test/ecdhtest.c index 636be3ee9d..16d8cedac1 100644 --- a/test/ecdhtest.c +++ b/test/ecdhtest.c @@ -516,7 +516,8 @@ int main(int argc, char *argv[]) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + ret = 1; #endif EXIT(ret); } diff --git a/test/ecdsatest.c b/test/ecdsatest.c index d098355be6..feb9f0a6eb 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -545,7 +545,8 @@ int main(void) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(out); + if (CRYPTO_mem_leaks(out) <= 0) + ret = 1; #endif BIO_free(out); return ret; diff --git a/test/ectest.c b/test/ectest.c index 674e593f44..03dfed96c9 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -1687,7 +1687,8 @@ int main(int argc, char *argv[]) ERR_free_strings(); ERR_remove_thread_state(NULL); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + return 1; #endif return 0; diff --git a/test/enginetest.c b/test/enginetest.c index 886bf68dae..d8dcca9cc3 100644 --- a/test/enginetest.c +++ b/test/enginetest.c @@ -249,7 +249,8 @@ int main(int argc, char *argv[]) ERR_free_strings(); ERR_remove_thread_state(NULL); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + to_return = 1; #endif return to_return; } diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 13dd262705..53844ad17d 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -467,7 +467,8 @@ int main(void) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + return 1; #endif printf("PASS\n"); diff --git a/test/evp_test.c b/test/evp_test.c index 6c9f4b8ece..ff2ee10c28 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -617,7 +617,8 @@ int main(int argc, char **argv) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + return 1; #endif if (t.errors) return 1; diff --git a/test/exptest.c b/test/exptest.c index 0acdacced7..5cd79e2970 100644 --- a/test/exptest.c +++ b/test/exptest.c @@ -300,7 +300,8 @@ int main(int argc, char *argv[]) BN_CTX_free(ctx); ERR_remove_thread_state(NULL); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(out); + if (CRYPTO_mem_leaks(out) <= 0) + goto err; #endif BIO_free(out); printf("\n"); diff --git a/test/jpaketest.c b/test/jpaketest.c index 7569f2e167..7b59855d23 100644 --- a/test/jpaketest.c +++ b/test/jpaketest.c @@ -179,7 +179,8 @@ int main(int argc, char **argv) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(bio_err); + if (CRYPTO_mem_leaks(bio_err) <= 0) + return 1; #endif return 0; diff --git a/test/p5_crpt2_test.c b/test/p5_crpt2_test.c index 303906fa9c..2c998bada3 100644 --- a/test/p5_crpt2_test.c +++ b/test/p5_crpt2_test.c @@ -206,7 +206,8 @@ int main(int argc, char **argv) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + return 1; # endif return 0; } diff --git a/test/rsa_test.c b/test/rsa_test.c index 0b707bf715..9f1f3d69d9 100644 --- a/test/rsa_test.c +++ b/test/rsa_test.c @@ -328,7 +328,8 @@ int main(int argc, char *argv[]) ERR_remove_thread_state(NULL); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + err = 1; #endif # ifdef OPENSSL_SYS_NETWARE diff --git a/test/srptest.c b/test/srptest.c index f6555a60e1..442a6101d4 100644 --- a/test/srptest.c +++ b/test/srptest.c @@ -147,7 +147,8 @@ int main(int argc, char **argv) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(bio_err); + if (CRYPTO_mem_leaks(bio_err) <= 0) + return 1; #endif BIO_free(bio_err); diff --git a/test/ssltest.c b/test/ssltest.c index 9cd2a53e50..f217a2073e 100644 --- a/test/ssltest.c +++ b/test/ssltest.c @@ -1865,7 +1865,8 @@ int main(int argc, char *argv[]) ERR_remove_thread_state(NULL); EVP_cleanup(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks(bio_err); + if (CRYPTO_mem_leaks(bio_err) <= 0) + ret = 1; #endif BIO_free(bio_err); EXIT(ret); diff --git a/test/verify_extra_test.c b/test/verify_extra_test.c index 843252051d..31c391ec1f 100644 --- a/test/verify_extra_test.c +++ b/test/verify_extra_test.c @@ -208,7 +208,8 @@ int main(int argc, char **argv) ERR_remove_thread_state(NULL); ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG - CRYPTO_mem_leaks_fp(stderr); + if (CRYPTO_mem_leaks_fp(stderr) <= 0) + return 1; #endif printf("PASS\n");