fix one-time leaks; make sure free'd stuff is NULL

This commit is contained in:
Pierangelo Masarati 2009-05-04 11:37:58 +00:00
parent 5c2b116798
commit b8022be3e6

View File

@ -237,6 +237,7 @@ slap_tool_init(
leakfile = stderr; leakfile = stderr;
} }
free( leakfilename ); free( leakfilename );
leakfilename = NULL;
#endif #endif
switch( tool ) { switch( tool ) {
@ -447,6 +448,7 @@ slap_tool_init(
#endif #endif
#ifdef HAVE_EBCDIC #ifdef HAVE_EBCDIC
free( logName ); free( logName );
logName = NULL;
#endif #endif
} }
#endif /* LDAP_DEBUG && LDAP_SYSLOG */ #endif /* LDAP_DEBUG && LDAP_SYSLOG */
@ -598,6 +600,9 @@ slap_tool_init(
fprintf( stderr, "Invalid filter '%s'\n", filterstr ); fprintf( stderr, "Invalid filter '%s'\n", filterstr );
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
ch_free( filterstr );
filterstr = NULL;
} }
if( subtree ) { if( subtree ) {
@ -613,6 +618,7 @@ slap_tool_init(
base = val; base = val;
} else { } else {
free( subtree ); free( subtree );
subtree = NULL;
} }
} }
@ -628,6 +634,7 @@ slap_tool_init(
be = select_backend( &nbase, 0 ); be = select_backend( &nbase, 0 );
ber_memfree( nbase.bv_val ); ber_memfree( nbase.bv_val );
BER_BVZERO( &nbase );
switch ( tool ) { switch ( tool ) {
case SLAPACL: case SLAPACL:
@ -650,6 +657,7 @@ slap_tool_init(
} }
ch_free( base.bv_val ); ch_free( base.bv_val );
BER_BVZERO( &base );
} else if ( dbnum == -1 ) { } else if ( dbnum == -1 ) {
/* no suffix and no dbnum specified, just default to /* no suffix and no dbnum specified, just default to
@ -723,10 +731,12 @@ startup:;
if ( conffile != NULL ) { if ( conffile != NULL ) {
ch_free( conffile ); ch_free( conffile );
conffile = NULL;
} }
if ( ldiffile != NULL ) { if ( ldiffile != NULL ) {
ch_free( ldiffile ); ch_free( ldiffile );
ldiffile = NULL;
} }
/* slapdn doesn't specify a backend to startup */ /* slapdn doesn't specify a backend to startup */
@ -781,6 +791,7 @@ int slap_tool_destroy( void )
if ( !BER_BVISNULL( &authcDN ) ) { if ( !BER_BVISNULL( &authcDN ) ) {
ch_free( authcDN.bv_val ); ch_free( authcDN.bv_val );
BER_BVZERO( &authcDN );
} }
if ( ldiffp && ldiffp != &dummy ) { if ( ldiffp && ldiffp != &dummy ) {