Update leak test to check return values.
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
This commit is contained in:
parent
4e482ae6ff
commit
ec04e86634
@ -56,23 +56,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
#include <openssl/crypto.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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||||
char *p;
|
char *p;
|
||||||
char *lost;
|
char *lost;
|
||||||
int aborted = 0;
|
int noleak;
|
||||||
|
|
||||||
p = getenv("OPENSSL_DEBUG_MEMORY");
|
p = getenv("OPENSSL_DEBUG_MEMORY");
|
||||||
if (p != NULL && strcmp(p, "on") == 0)
|
if (p != NULL && strcmp(p, "on") == 0)
|
||||||
@ -85,18 +75,16 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGABRT, handler);
|
|
||||||
|
|
||||||
if (argv[1] && strcmp(argv[1], "freeit") == 0) {
|
if (argv[1] && strcmp(argv[1], "freeit") == 0) {
|
||||||
OPENSSL_free(lost);
|
OPENSSL_free(lost);
|
||||||
lost = NULL;
|
lost = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sigsetjmp(env, 0) == 0)
|
noleak = CRYPTO_mem_leaks_fp(stderr);
|
||||||
CRYPTO_mem_leaks_fp(stderr);
|
/* If -1 return value something bad happened */
|
||||||
else
|
if (noleak == -1)
|
||||||
aborted = 1;
|
return 1;
|
||||||
return ((lost != NULL) ^ (aborted == 1));
|
return ((lost != NULL) ^ (noleak == 0));
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user