提交 4a4c4bf0 编写于 作者: D Dr. Stephen Henson

Add memory leak detection to d2i_test

Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1707)
上级 32804b04
...@@ -142,6 +142,7 @@ int main(int argc, char **argv) ...@@ -142,6 +142,7 @@ int main(int argc, char **argv)
int result = 0; int result = 0;
const char *test_type_name; const char *test_type_name;
const char *expected_error_string; const char *expected_error_string;
const char *p = getenv("OPENSSL_DEBUG_MEMORY");
size_t i; size_t i;
...@@ -153,6 +154,10 @@ int main(int argc, char **argv) ...@@ -153,6 +154,10 @@ int main(int argc, char **argv)
{"compare", ASN1_COMPARE} {"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) { if (argc != 4) {
fprintf(stderr, fprintf(stderr,
"Usage: d2i_test item_name expected_error file.der\n"); "Usage: d2i_test item_name expected_error file.der\n");
...@@ -194,5 +199,10 @@ int main(int argc, char **argv) ...@@ -194,5 +199,10 @@ int main(int argc, char **argv)
result = run_tests(argv[0]); result = run_tests(argv[0]);
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (CRYPTO_mem_leaks_fp(stderr) <= 0)
result = 1;
#endif
return result; return result;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册