From 9ab9162f4d400e2fb8fced938b7692859ae6bf7d Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 15 Dec 2007 11:51:20 +0000 Subject: [PATCH] fix one-time leaks --- clients/tools/common.c | 11 +++++++++++ clients/tools/ldapsearch.c | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clients/tools/common.c b/clients/tools/common.c index 6fb304a6ec..cfbe29bf9a 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -223,6 +223,17 @@ tool_destroy( void ) #ifdef HAVE_TLS ldap_pvt_tls_destroy(); #endif + + if ( ldapuri != NULL ) { + ber_memfree( ldapuri ); + ldapuri = NULL; + } + + if ( pr_cookie.bv_val != NULL ) { + ber_memfree( pr_cookie.bv_val ); + pr_cookie.bv_val = NULL; + pr_cookie.bv_len = 0; + } } void diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index f5312a27b8..6ca5d274dd 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -95,6 +95,8 @@ static int attrsonly; static int timelimit = -1; static int sizelimit = -1; +static char *control; + static char *def_tmpdir; static char *def_urlpre; @@ -255,7 +257,7 @@ int handle_private_option( int i ) { int crit, ival; - char *control, *cvalue, *next; + char *cvalue, *next; switch ( i ) { case 'a': /* set alias deref option */ if ( strcasecmp( optarg, "never" ) == 0 ) { @@ -1040,6 +1042,12 @@ getNextPage: tool_unbind( ld ); tool_destroy(); + if ( base != NULL ) { + ber_memfree( base ); + } + if ( control != NULL ) { + ber_memfree( control ); + } if ( c ) { for ( ; save_nctrls-- > 0; ) { -- 2.39.5