summaryrefslogtreecommitdiffstats
path: root/test/d2i_test.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-10-13 16:10:21 +0100
committerDr. Stephen Henson <steve@openssl.org>2016-10-13 19:27:34 +0100
commit91951307d63cd238e2603cc739b765a909f35785 (patch)
treef68e53987189b8c8f8f7ad9e9b993f151f919535 /test/d2i_test.c
parent5c0c82c3f6e43b3c44d584f9c64cdc515fa30091 (diff)
Add memory leak detection to d2i_test
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1707) (cherry picked from commit 4a4c4bf06d6362f56507c787c61b07655563e962)
Diffstat (limited to 'test/d2i_test.c')
-rw-r--r--test/d2i_test.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/d2i_test.c b/test/d2i_test.c
index 8c99087732..8dbb8f14ec 100644
--- a/test/d2i_test.c
+++ b/test/d2i_test.c
@@ -142,6 +142,7 @@ int main(int argc, char **argv)
int result = 0;
const char *test_type_name;
const char *expected_error_string;
+ const char *p = getenv("OPENSSL_DEBUG_MEMORY");
size_t i;
static ASN1_ITEM_EXP *items[] = {
@@ -159,6 +160,10 @@ int main(int argc, char **argv)
{"compare", ASN1_COMPARE}
};
+ if (p != NULL && strcmp(p, "on") == 0)
+ CRYPTO_set_mem_debug(1);
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
+
if (argc != 4) {
fprintf(stderr,
"Usage: d2i_test item_name expected_error file.der\n");
@@ -202,5 +207,10 @@ int main(int argc, char **argv)
result = run_tests(argv[0]);
+#ifndef OPENSSL_NO_CRYPTO_MDEBUG
+ if (CRYPTO_mem_leaks_fp(stderr) <= 0)
+ result = 1;
+#endif
+
return result;
}