Skip to content

Commit

Permalink
Enable/disable crypto-mdebug just like other features
Browse files Browse the repository at this point in the history
Also always abort() on leak failure.

Reviewed-by: Stephen Henson <[email protected]>
  • Loading branch information
Viktor Dukhovni authored and snhenson committed Jan 11, 2016
1 parent 3af45d9 commit c2e2731
Show file tree
Hide file tree
Showing 32 changed files with 102 additions and 98 deletions.
12 changes: 6 additions & 6 deletions Configurations/10-main.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"vos-gcc" => {
cc => "gcc",
cflags => "-Wall -DOPENSSL_SYS_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN",
debug_cflags => "-O0 -g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG",
debug_cflags => "-O0 -g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG",
release_cflags => "-O3",
thread_cflag => "(unknown)",
sys_id => "VOS",
Expand Down Expand Up @@ -132,7 +132,7 @@
# -mcpu=ultrasparc
inherit_from => [ "solaris-sparcv7-gcc", asm("sparcv9_asm") ],
cflags => sub { join(" ","-m32 -mcpu=ultrasparc",@_); },
debug_cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -O -g -pedantic -ansi -Wshadow -Wno-long-long -D__EXTENSIONS__",
debug_cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -O -g -pedantic -ansi -Wshadow -Wno-long-long -D__EXTENSIONS__",
},
"solaris64-sparcv9-gcc" => {
inherit_from => [ "solaris-sparcv9-gcc" ],
Expand All @@ -150,7 +150,7 @@
inherit_from => [ "solaris-common" ],
cc => "cc",
cflags => sub { join(" ","-xstrconst -Xa -DB_ENDIAN -DBN_DIV2W",@_) },
debug_cflags => "-g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG",
debug_cflags => "-g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG",
release_cflags => "-xO5 -xdepend",
thread_cflag => "-D_REENTRANT",
lflags => sub { join(" ",@_,"-mt -lpthread") },
Expand Down Expand Up @@ -501,7 +501,7 @@
"linux-generic32" => {
cc => "gcc",
cflags => "-Wall",
debug_cflags => "-O0 -g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG",
debug_cflags => "-O0 -g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG",
release_cflags => "-O3",
thread_cflag => "-pthread",
lflags => "-ldl",
Expand Down Expand Up @@ -612,7 +612,7 @@
inherit_from => [ "linux-generic32", asm("x86_elf_asm") ],
cc => "gcc",
cflags => "-march=i486 -DL_ENDIAN -Wall",
debug_cflags => "-O0 -g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG",
debug_cflags => "-O0 -g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG",
release_cflags => "-O3 -fomit-frame-pointer",
debug_lflags => "-lefence",
bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
Expand Down Expand Up @@ -1450,7 +1450,7 @@
},
"vxworks-ppc750-debug" => {
cc => "ccppc",
cflags => "-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g",
cflags => "-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g",
sys_id => "VXWORKS",
lflags => "-r",
},
Expand Down
10 changes: 5 additions & 5 deletions Configurations/90-team.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
},
"debug" => {
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror",
thread_cflag => "(unknown)",
lflags => "-lefence",
},
"debug-erbridge" => {
inherit_from => [ "x86_64_asm" ],
cc => "gcc",
cflags => "$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -DTERMIO -g",
cflags => "$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL",
Expand All @@ -36,7 +36,7 @@
"debug-linux-pentium" => {
inherit_from => [ "x86_elf_asm" ],
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -g -mcpu=pentium -Wall",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentium -Wall",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
Expand All @@ -45,7 +45,7 @@
"debug-linux-ppro" => {
inherit_from => [ "x86_elf_asm" ],
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -g -mcpu=pentiumpro -Wall",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentiumpro -Wall",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
Expand All @@ -54,7 +54,7 @@
"debug-linux-elf-noefence" => {
inherit_from => [ "x86_elf_asm" ],
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -g -march=i486 -Wall",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -march=i486 -Wall",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
Expand Down
10 changes: 5 additions & 5 deletions Configurations/99-personal-ben.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
%targets = (
"debug-ben" => {
cc => "gcc",
cflags => "$gcc_devteam_warn -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DDEBUG_SAFESTACK -O2 -pipe",
cflags => "$gcc_devteam_warn -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -O2 -pipe",
thread_cflag => "(unknown)",
},
"debug-ben-openbsd" => {
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe",
thread_cflag => "(unknown)",
},
"debug-ben-openbsd-debug" => {
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe",
thread_cflag => "(unknown)",
},
"debug-ben-debug" => {
Expand Down Expand Up @@ -69,12 +69,12 @@
},
"debug-ben-no-opt" => {
cc => "gcc",
cflags => " -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG -Werror -DL_ENDIAN -Wall -g3",
cflags => " -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -Werror -DL_ENDIAN -Wall -g3",
thread_cflag => "(unknown)",
},
"debug-ben-strict" => {
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe",
cflags => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe",
thread_cflag => "(unknown)",
},
"debug-ben-darwin64" => {
Expand Down
8 changes: 4 additions & 4 deletions Configurations/99-personal-levitte.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
inherit_from => [ "x86_elf_asm" ],
cc => "gcc",
cflags => "-DL_ENDIAN -Wall",
debug_cflags => "-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG-ggdb -g3",
debug_cflags => "-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -ggdb -g3",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT",
Expand All @@ -22,7 +22,7 @@
"debug-levitte-linux-noasm" => {
inherit_from => [ "no_asm_filler" ],
cc => "gcc",
cflags => "-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -ggdb -g3 -Wall",
cflags => "-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -ggdb -g3 -Wall",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT",
Expand All @@ -34,7 +34,7 @@
"debug-levitte-linux-elf-extreme" => {
inherit_from => [ "x86_elf_asm" ],
cc => "gcc",
cflags => "-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe",
cflags => "-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DENGINE_CONF_DEBUG -DL_ENDIAN -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT",
Expand All @@ -47,7 +47,7 @@
"debug-levitte-linux-noasm-extreme" => {
inherit_from => [ "no_asm_filler" ],
cc => "gcc",
cflags => "-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe",
cflags => "-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe",
thread_cflag => "-D_REENTRANT",
lflags => "-ldl",
bn_ops => "BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT",
Expand Down
7 changes: 4 additions & 3 deletions Configure
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
# Minimum warning options... any contributions to OpenSSL should at least get
# past these.

my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DCRYPTO_MDEBUG -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DDEBUG_UNUSED";
my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DREF_CHECK -DDEBUG_UNUSED";

# These are used in addition to $gcc_devteam_warn when the compiler is clang.
# TODO(openssl-team): fix problems and investigate if (at least) the
Expand Down Expand Up @@ -908,13 +908,14 @@ my %disabled = ( # "what" => "comment" [or special keyword "experimental
"jpake" => "experimental",
"md2" => "default",
"rc5" => "default",
"sctp" => "default",
"sctp" => "default",
"shared" => "default",
"ssl-trace" => "default",
"store" => "experimental",
"unit-test" => "default",
"zlib" => "default",
"zlib-dynamic" => "default"
"zlib-dynamic" => "default",
"crypto-mdebug" => "default",
);
my @experimental = ();

Expand Down
1 change: 0 additions & 1 deletion Makefile.org
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ OPENSSLDIR=/usr/local/ssl
# LOCK_DEBUG - turns on lots of lock debug output :-)
# REF_CHECK - turn on some xyz_free() assertions.
# REF_PRINT - prints some stuff on structure free.
# CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff
# MFUNC - Make all Malloc/Free/Realloc calls call
# CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
# call application defined callbacks via CRYPTO_set_mem_functions()
Expand Down
2 changes: 1 addition & 1 deletion apps/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ int main(int argc, char *argv[])
BIO_free(bio_in);
BIO_free_all(bio_out);
apps_shutdown();
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
CRYPTO_mem_leaks(bio_err);
#endif
BIO_free(bio_err);
Expand Down
16 changes: 8 additions & 8 deletions crypto/asn1/tasn_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
else
asn1_cb = 0;

#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new");
#endif

Expand Down Expand Up @@ -135,7 +135,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
if (!i)
goto auxerr;
if (i == 2) {
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_pop();
#endif
return 1;
Expand All @@ -160,7 +160,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
if (!i)
goto auxerr;
if (i == 2) {
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_pop();
#endif
return 1;
Expand All @@ -184,22 +184,22 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
goto auxerr;
break;
}
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_pop();
#endif
return 1;

memerr:
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE);
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_pop();
#endif
return 0;

auxerr:
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR);
ASN1_item_ex_free(pval, it);
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_pop();
#endif
return 0;
Expand Down Expand Up @@ -259,7 +259,7 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
*pval = NULL;
return 1;
}
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_push(tt->field_name
? tt->field_name : "asn1_template_new");
#endif
Expand All @@ -279,7 +279,7 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
/* Otherwise pass it back to the item routine */
ret = asn1_item_embed_new(pval, it, embed);
done:
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
OPENSSL_mem_debug_pop();
#endif
return ret;
Expand Down
10 changes: 5 additions & 5 deletions crypto/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static void *(*realloc_wrapper)(void *, size_t, const char *, int)
static void (*free_wrapper)(void *)
= CRYPTO_free;

#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
static int call_malloc_debug = 1;
#else
static int call_malloc_debug = 0;
Expand Down Expand Up @@ -125,7 +125,7 @@ void *CRYPTO_malloc(size_t num, const char *file, int line)
return NULL;

allow_customize = 0;
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (call_malloc_debug) {
CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);
ret = malloc(num);
Expand Down Expand Up @@ -174,7 +174,7 @@ void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
}

allow_customize = 0;
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (call_malloc_debug) {
void *ret;
CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);
Expand Down Expand Up @@ -211,7 +211,7 @@ void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,

/* Allocate new memory. Call malloc and do a copy, so that we can
* cleanse the old buffer. */
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (call_malloc_debug) {
CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);
ret = malloc(num);
Expand All @@ -233,7 +233,7 @@ void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,

void CRYPTO_free(void *str)
{
#ifdef CRYPTO_MDEBUG
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (call_malloc_debug) {
CRYPTO_mem_debug_free(str, 0);
free(str);
Expand Down
6 changes: 3 additions & 3 deletions crypto/mem_dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@
* checking temporarily. State CRYPTO_MEM_CHECK_ENABLE without ..._ON makes
* no sense whatsoever.
*/
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
static int mh_mode = CRYPTO_MEM_CHECK_OFF;
#endif

#ifndef OPENSSL_NO_CRYPTO_MDEBUG
static unsigned long order = 0; /* number of memory requests */
Expand Down Expand Up @@ -203,7 +205,7 @@ static void app_info_free(APP_INFO *inf)

int CRYPTO_mem_ctrl(int mode)
{
#ifndef CRYPTO_MDEBUG
#ifdef OPENSSL_NO_CRYPTO_MDEBUG
return mode - mode;
#else
int ret = mh_mode;
Expand Down Expand Up @@ -663,9 +665,7 @@ void CRYPTO_mem_leaks(BIO *b)
}
if (ml.chunks != 0) {
BIO_printf(b, "%ld bytes leaked in %d chunks\n", ml.bytes, ml.chunks);
# ifdef CRYPTO_MDEBUG_ABORT
abort();
# endif
} else {
/*
* Make sure that, if we found no leaks, memory-leak debugging itself
Expand Down
Loading

0 comments on commit c2e2731

Please sign in to comment.