struct metasingleconn *lsc;
char *rmsg = NULL;
char *rmatch = NULL;
+ int free_rmsg = 0, free_rmatch = 0;
for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
char *msg = NULL;
switch ( rs->sr_err ) {
default:
rerr = rs->sr_err;
+ if ( rmsg ) {
+ ber_memfree( rmsg );
+ }
rmsg = msg;
+ free_rmsg = 1;
msg = NULL;
+ if ( rmatch ) {
+ ber_memfree( rmatch );
+ }
rmatch = match;
+ free_rmatch = 1;
match = NULL;
break;
}
rs->sr_text = rmsg;
rs->sr_matched = rmatch;
send_ldap_result( op, rs );
+ if ( free_rmsg ) {
+ ber_memfree( rmsg );
+ }
+ if ( free_rmatch ) {
+ ber_memfree( rmatch );
+ }
rs->sr_text = NULL;
rs->sr_matched = NULL;
return rs->sr_err;
}
+ /* copy the DN idf needed */
+ if ( lsc->bound_dn.bv_val == op->o_conn->c_dn.bv_val ) {
+ ber_dupbv( &lsc->bound_dn, &op->o_conn->c_dn );
+ }
+
assert( lsc->bound_dn.bv_val );
} else {
struct metaconn *lc;
struct metasingleconn *lsc;
struct timeval tv = { 0, 0 };
- LDAPMessage *res, *e;
+ LDAPMessage *res = NULL, *e;
int rc = 0, *msgid, sres = LDAP_SUCCESS;
char *err = NULL;
struct berval match = { 0, NULL }, mmatch = { 0, NULL };
0, &tv, &res );
if ( rc == 0 ) {
+ /* timeout exceeded */
+
+ /* FIXME: res should not need to be freed */
+ assert( res == NULL );
+
continue;
} else if ( rc == -1 ) {
send_ldap_result( op, rs );
/* anything else needs be done? */
+
+ /* FIXME: res should not need to be freed */
+ assert( res == NULL );
+
goto finish;
} else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
e = ldap_first_entry( lsc->ld, res );
meta_send_entry( op, rs, lc, i, e );
+ ldap_msgfree( res );
+ res = NULL;
+
/*
* If scope is BASE, we need to jump out
* as soon as one entry is found; if
sres = LDAP_SUCCESS;
break;
}
- ldap_msgfree( res );
+
gotit = 1;
} else if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
rs->sr_ctrls = NULL;
}
+ ldap_msgfree( res );
+ res = NULL;
+
} else {
rs->sr_err = ldap_result2error( lsc->ld,
res, 1 );
+ res = NULL;
+
sres = ldap_back_map_result( rs );
if ( err != NULL ) {
free( err );