From: Howard Chu Date: Wed, 24 Sep 2003 00:32:27 +0000 (+0000) Subject: ITS#2735 - plug memory leaks X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~662 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7fd47cedb70a25cf09cfdb0a9bce6bf0f57fc43c;p=openldap ITS#2735 - plug memory leaks --- diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 546a241581..000f801167 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -268,7 +268,7 @@ static int set( Slapi_PBlock *pb, int param, void *val ) { #if defined(LDAP_SLAPI) - int i; + int i, freeit; if ( isValidParam( pb, param ) == INVALID_PARAM ) { return PBLOCK_ERROR; @@ -281,6 +281,17 @@ set( Slapi_PBlock *pb, int param, void *val ) return PBLOCK_ERROR; } + switch ( param ) { + case SLAPI_CONN_DN: + case SLAPI_CONN_AUTHMETHOD: + case SLAPI_IBM_CONN_DN_ALT: + case SLAPI_IBM_CONN_DN_ORIG: + case SLAPI_RESULT_TEXT: + case SLAPI_RESULT_MATCHED: + freeit = 1; break; + default: + freeit = 0; break; + } for( i = 0; i < pb->numParams; i++ ) { if ( pb->curParams[i] == param ) { break; @@ -291,6 +302,7 @@ set( Slapi_PBlock *pb, int param, void *val ) pb->curParams[i] = param; pb->numParams++; } + if ( freeit ) ch_free( pb->curVals[i] ); pb->curVals[i] = val; unLock( pb ); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 1bc7311292..ab531019eb 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -2244,13 +2244,15 @@ static int initConnectionPB( Slapi_PBlock *pb, Connection *conn ) 0 ); if ( connAuthType != NULL ) { rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHMETHOD, (void *)connAuthType); + /* slapi_pblock_set dups this itself */ + slapi_ch_free( (void **)&connAuthType ); if ( rc != LDAP_SUCCESS ) return rc; } if ( conn->c_authz.sai_dn.bv_val != NULL ) { - char *connDn = slapi_ch_strdup(conn->c_authz.sai_dn.bv_val); - rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn); + /* slapi_pblock_set dups this itself */ + rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)conn->c_authz.sai_dn.bv_val); if ( rc != LDAP_SUCCESS ) return rc; } @@ -3741,8 +3743,6 @@ int slapi_x_access_allowed( Operation *op, return 1; } - slapi_x_pblock_set_operation( op->o_pb, op ); - switch ( access ) { case ACL_WRITE: slap_access |= SLAPI_ACL_ADD | SLAPI_ACL_DELETE | SLAPI_ACL_WRITE; @@ -3766,6 +3766,8 @@ int slapi_x_access_allowed( Operation *op, return 1; } + slapi_x_pblock_set_operation( op->o_pb, op ); + rc = 1; /* default allow policy */ for ( pGetPlugin = tmpPlugin; *pGetPlugin != NULL; pGetPlugin++ ) {