summaryrefslogtreecommitdiffstats
path: root/test/memleaktest.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-01-11 00:29:46 +0100
committerDr. Stephen Henson <steve@openssl.org>2016-01-11 03:41:16 +0100
commitec04e866343d40a1e3e8e5db79557e279a2dd0d8 (patch)
tree69ee80a3a5fc6a459ced904cf8e537df046e35b6 /test/memleaktest.c
parentAdd memory leak return value. (diff)
downloadopenssl-ec04e866343d40a1e3e8e5db79557e279a2dd0d8.tar.xz
openssl-ec04e866343d40a1e3e8e5db79557e279a2dd0d8.zip
Update leak test to check return values.
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Diffstat (limited to 'test/memleaktest.c')
-rw-r--r--test/memleaktest.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/test/memleaktest.c b/test/memleaktest.c
index cdb61a3608..f8945904ac 100644
--- a/test/memleaktest.c
+++ b/test/memleaktest.c
@@ -56,23 +56,13 @@
#include <string.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
-#include <setjmp.h>
-
-#ifndef OPENSSL_NO_CRYPTO_MDEBUG
-static sigjmp_buf env;
-
-static void handler(int sig)
-{
- siglongjmp(env, 1);
-}
-#endif
int main(int argc, char **argv)
{
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
char *p;
char *lost;
- int aborted = 0;
+ int noleak;
p = getenv("OPENSSL_DEBUG_MEMORY");
if (p != NULL && strcmp(p, "on") == 0)
@@ -85,18 +75,16 @@ int main(int argc, char **argv)
return 1;
}
- signal(SIGABRT, handler);
-
if (argv[1] && strcmp(argv[1], "freeit") == 0) {
OPENSSL_free(lost);
lost = NULL;
}
- if (sigsetjmp(env, 0) == 0)
- CRYPTO_mem_leaks_fp(stderr);
- else
- aborted = 1;
- return ((lost != NULL) ^ (aborted == 1));
+ noleak = CRYPTO_mem_leaks_fp(stderr);
+ /* If -1 return value something bad happened */
+ if (noleak == -1)
+ return 1;
+ return ((lost != NULL) ^ (noleak == 0));
#else
return 0;
#endif