diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index 6e929110f5c08e6c444980d0e8db0750035deede..4f4afa390f1f486a30764b3afa06b6fce7b012c6 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -204,11 +204,8 @@ ber_free_buf( BerElement *ber ) void ber_free( BerElement *ber, int freebuf ) { -#ifdef LDAP_MEMORY_DEBUG - assert( ber != NULL ); -#endif - if( ber == NULL ) { + LDAP_MEMORY_DEBUG_ASSERT( ber != NULL ); return; } diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index 24d0dac0929240e9097793d32c29b334fc439590..e2657d2eb1d21695b04d8e99ec3f30bfcb2c9f8a 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -47,6 +47,11 @@ LBER_V (BER_ERRNO_FN) ber_int_errno_fn; #ifdef LDAP_MEMORY_DEBUG LBER_V (long) ber_int_meminuse; #endif +#if defined(LDAP_MEMORY_DEBUG) && ((LDAP_MEMORY_DEBUG +0) & 2) +# define LDAP_MEMORY_DEBUG_ASSERT assert +#else +# define LDAP_MEMORY_DEBUG_ASSERT(expr) ((void) 0) +#endif struct lber_options { short lbo_valid; diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c index 3f569f7f8aa9666caf42d0f31e0878ab34e77fcb..94ef772d97dbe169807c261b6840bcd9dcf23216 100644 --- a/libraries/liblber/memory.c +++ b/libraries/liblber/memory.c @@ -28,9 +28,11 @@ /* * LDAP_MEMORY_DEBUG should only be enabled for the purposes of * debugging memory management within OpenLDAP libraries and slapd. - * It should only be enabled by an experienced developer as it - * causes the inclusion of numerous assert()'s, many of which may - * be triggered by a prefectly valid program. + * + * It should only be enabled by an experienced developer as it causes + * the inclusion of numerous assert()'s, many of which may be triggered + * by a prefectly valid program. If LDAP_MEMORY_DEBUG & 2 is true, + * that includes asserts known to break both slapd and current clients. * * The code behind this macro is subject to change as needed to * support this testing. @@ -192,11 +194,8 @@ ber_memalloc_x( ber_len_t s, void *ctx ) { void *new; -#ifdef LDAP_MEMORY_DEBUG - assert( s != 0 ); -#endif - if( s == 0 ) { + LDAP_MEMORY_DEBUG_ASSERT( s != 0 ); return NULL; } @@ -248,11 +247,8 @@ ber_memcalloc_x( ber_len_t n, ber_len_t s, void *ctx ) { void *new; -#ifdef LDAP_MEMORY_DEBUG - assert( n != 0 && s != 0); -#endif - if( n == 0 || s == 0 ) { + LDAP_MEMORY_DEBUG_ASSERT( n != 0 && s != 0); return NULL; } diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c index faca9839ecbf4fb7c1258239200246e720f305c0..51fde85a51c3c7a601b2b4aac5515be3108876cb 100644 --- a/libraries/libldap/controls.c +++ b/libraries/libldap/controls.c @@ -246,9 +246,7 @@ int ldap_pvt_get_controls( void ldap_control_free( LDAPControl *c ) { -#ifdef LDAP_MEMORY_DEBUG - assert( c != NULL ); -#endif + LDAP_MEMORY_DEBUG_ASSERT( c != NULL ); if ( c != NULL ) { if( c->ldctl_oid != NULL) { @@ -269,9 +267,7 @@ ldap_control_free( LDAPControl *c ) void ldap_controls_free( LDAPControl **controls ) { -#ifdef LDAP_MEMORY_DEBUG - assert( controls != NULL ); -#endif + LDAP_MEMORY_DEBUG_ASSERT( controls != NULL ); if ( controls != NULL ) { int i;