From d0dd945882d1019a5252743495ea022646373fbe Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 15 Jul 2008 08:54:41 +0000 Subject: [PATCH] fix potential leak in previous commit --- servers/slapd/back-ldap/search.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 91f3508ae4..430162f57c 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -97,7 +97,12 @@ ldap_back_munge_filter( /* if undef or invalid filter is not allowed, * don't rewrite filter */ if ( LDAP_BACK_NOUNDEFFILTER( li ) ) { - return -1; + if ( filter->bv_val != op->ors_filterstr.bv_val ) { + op->o_tmpfree( filter->bv_val, op->o_tmpmemctx ); + } + BER_BVZERO( filter ); + gotit = -1; + goto done; } oldbv = &bv_undefined; @@ -156,7 +161,6 @@ ldap_back_search( msgid; struct berval match = BER_BVNULL, filter = BER_BVNULL; - int free_filter = 0; int i; char **attrs = NULL; int freetext = 0; @@ -244,18 +248,13 @@ retry: goto finish; case LDAP_FILTER_ERROR: - switch (ldap_back_munge_filter( op, &filter ) ) { - case 0: - case -1: - /* invalid filters return success with no data */ - rs->sr_err = LDAP_SUCCESS; - rs->sr_text = NULL; - break; - - case 1: - free_filter = 1; + if (ldap_back_munge_filter( op, &filter ) > 0 ) { goto retry; } + + /* invalid filters return success with no data */ + rs->sr_err = LDAP_SUCCESS; + rs->sr_text = NULL; goto finish; default: @@ -558,7 +557,7 @@ finish:; rs->sr_matched = save_matched; } - if ( free_filter ) { + if ( filter.bv_val != op->ors_filterstr.bv_val ) { op->o_tmpfree( filter.bv_val, op->o_tmpmemctx ); } -- 2.39.5