]> git.sur5r.net Git - openldap/commitdiff
ITS#2735 - plug memory leaks
authorHoward Chu <hyc@openldap.org>
Wed, 24 Sep 2003 00:32:27 +0000 (00:32 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 24 Sep 2003 00:32:27 +0000 (00:32 +0000)
servers/slapd/slapi/slapi_pblock.c
servers/slapd/slapi/slapi_utils.c

index 546a241581e6a668547ee43c36013708595114de..000f8011671c2efef0171f24aab234b042aa73de 100644 (file)
@@ -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 );   
index 1bc731129214ed72a11406509a3e1f6325407085..ab531019eb8f49e79366c1b3f99a8b988aeb1fc5 100644 (file)
@@ -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++ ) {