]> git.sur5r.net Git - openldap/commitdiff
fix various memory leaks and handling issues
authorPierangelo Masarati <ando@openldap.org>
Tue, 6 Dec 2005 22:06:29 +0000 (22:06 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 6 Dec 2005 22:06:29 +0000 (22:06 +0000)
servers/slapd/back-sql/delete.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/modrdn.c
servers/slapd/back-sql/search.c

index 0ee1ec2ecd55f3e3a84240b21ae4807d7325290e..31087f081c25b140f6364c256a4e9356c2376381 100644 (file)
@@ -480,6 +480,11 @@ done:;
                backsql_entry_clean( op, &p );
        }
 
+       if ( rs->sr_ref ) {
+               ber_bvarray_free( rs->sr_ref );
+               rs->sr_ref = NULL;
+       }
+
        return rs->sr_err;
 }
 
index 2f836d4b4c00e3aee1e5443e2a5f0e63a1536d13..337df17ad9262d5ffb59c593afdb7bc1815b026e 100644 (file)
@@ -204,6 +204,11 @@ done:;
                op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
        }
 
+       if ( rs->sr_ref ) {
+               ber_bvarray_free( rs->sr_ref );
+               rs->sr_ref = NULL;
+       }
+
        Debug( LDAP_DEBUG_TRACE, "<==backsql_modify()\n", 0, 0, 0 );
 
        return rs->sr_err;
index a6aca06c96eee281873fb0f68bc3e6c1693b9dc3..25462231d71555055e33e74391b200d82161ba51 100644 (file)
@@ -556,10 +556,17 @@ done:;
        }
        if ( mod != NULL ) {
                Modifications *tmp;
-               for (; mod; mod = tmp ) {
+               for (; mod; mod=tmp ) {
                        tmp = mod->sml_next;
+                       /* slap_modrdn2mods does things one way,
+                        * slap_mods_opattrs does it differently
+                        */
+                       if ( mod->sml_op != SLAP_MOD_SOFTADD &&
+                               mod->sml_op != LDAP_MOD_DELETE ) break;
+                       if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
                        free( mod );
                }
+               slap_mods_free( mod, 1 );
        }
 
        if ( !BER_BVISNULL( &e_id.eid_ndn ) ) {
@@ -582,6 +589,11 @@ done:;
                backsql_entry_clean( op, &n );
        }
 
+       if ( rs->sr_ref ) {
+               ber_bvarray_free( rs->sr_ref );
+               rs->sr_ref = NULL;
+       }
+
        Debug( LDAP_DEBUG_TRACE, "<==backsql_modrdn()\n", 0, 0, 0 );
 
        return rs->sr_err;
index ba54bef33bd02628346ea6a177b7b38786e606b7..95c593b5c079a379c61db2d4e596915377e2bb2c 100644 (file)
@@ -1517,16 +1517,16 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
                BER_BVZERO( query );
        }
  
-       free( bsi->bsi_sel.bb_val.bv_val );
+       bsi->bsi_op->o_tmpfree( bsi->bsi_sel.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
        BER_BVZERO( &bsi->bsi_sel.bb_val );
        bsi->bsi_sel.bb_len = 0;
-       free( bsi->bsi_from.bb_val.bv_val );
+       bsi->bsi_op->o_tmpfree( bsi->bsi_from.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
        BER_BVZERO( &bsi->bsi_from.bb_val );
        bsi->bsi_from.bb_len = 0;
-       free( bsi->bsi_join_where.bb_val.bv_val );
+       bsi->bsi_op->o_tmpfree( bsi->bsi_join_where.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
        BER_BVZERO( &bsi->bsi_join_where.bb_val );
        bsi->bsi_join_where.bb_len = 0;
-       free( bsi->bsi_flt_where.bb_val.bv_val );
+       bsi->bsi_op->o_tmpfree( bsi->bsi_flt_where.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
        BER_BVZERO( &bsi->bsi_flt_where.bb_val );
        bsi->bsi_flt_where.bb_len = 0;
        
@@ -1620,7 +1620,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
                        query.bv_val, 0, 0 );
 
        rc = backsql_Prepare( bsi->bsi_dbh, &sth, query.bv_val, 0 );
-       free( query.bv_val );
+       bsi->bsi_op->o_tmpfree( query.bv_val, bsi->bsi_op->o_tmpmemctx );
        BER_BVZERO( &query );
        if ( rc != SQL_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
@@ -1970,7 +1970,7 @@ backsql_search( Operation *op, SlapReply *rs )
        default:
 #ifdef SLAP_ACL_HONOR_DISCLOSE
                if ( !BER_BVISNULL( &base_entry.e_nname )
-                               && ! access_allowed( op, &base_entry,
+                               && !access_allowed( op, &base_entry,
                                        slap_schema.si_ad_entry, NULL,
                                        ACL_DISCLOSE, NULL ) )
                {
@@ -1991,6 +1991,10 @@ backsql_search( Operation *op, SlapReply *rs )
                        rs->sr_ref = NULL;
                }
 
+               if ( !BER_BVISNULL( &base_entry.e_nname ) ) {
+                       entry_clean( &base_entry );
+               }
+
                goto done;
        }
 #ifdef SLAP_ACL_HONOR_DISCLOSE