]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/translucent.c
fix one-time leak
[openldap] / servers / slapd / overlays / translucent.c
index a6ffc7d28ac58bcccf3c97d5f8cca517c0f8972a..bc560aba0775768ff95834e017ae8bd8a38a6ed5 100644 (file)
@@ -364,11 +364,10 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
                                        m->sml_desc->ad_cname.bv_val, 0, 0);
                                for(mm = op->orm_modlist; mm->sml_next != m; mm = mm->sml_next);
                                mm->sml_next = m->sml_next;
-                               mm = m;
-                               m = m->sml_next;
-                               mm->sml_next = NULL;            /* hack */
-                               slap_mods_free(mm, 1);
-                               if(m) continue;
+                               m->sml_next = NULL;
+                               slap_mods_free(m, 1);
+                               m = mm;
+                               continue;
                        }
                        m->sml_op = LDAP_MOD_ADD;
                }
@@ -742,15 +741,17 @@ static int translucent_db_open(BackendDB *be) {
 **
 */
 
-static int translucent_db_close(BackendDB *be) {
+static int
+translucent_db_close( BackendDB *be )
+{
        slap_overinst *on = (slap_overinst *) be->bd_info;
        translucent_info *ov = on->on_bi.bi_private;
        int rc = 0;
 
        Debug(LDAP_DEBUG_TRACE, "==> translucent_db_close\n", 0, 0, 0);
 
-       if ( ov ) {
-               rc = (ov->db.bd_info && ov->db.bd_info->bi_db_close) ? ov->db.bd_info->bi_db_close(&ov->db) : 0;
+       if ( ov && ov->db.bd_info && ov->db.bd_info->bi_db_close ) {
+               rc = ov->db.bd_info->bi_db_close(&ov->db);
        }
 
        return(rc);
@@ -762,7 +763,9 @@ static int translucent_db_close(BackendDB *be) {
 **
 */
 
-static int translucent_db_destroy(BackendDB *be) {
+static int
+translucent_db_destroy( BackendDB *be )
+{
        slap_overinst *on = (slap_overinst *) be->bd_info;
        translucent_info *ov = on->on_bi.bi_private;
        int rc = 0;
@@ -770,7 +773,18 @@ static int translucent_db_destroy(BackendDB *be) {
        Debug(LDAP_DEBUG_TRACE, "==> translucent_db_close\n", 0, 0, 0);
 
        if ( ov ) {
-               rc = (ov->db.bd_info && ov->db.bd_info->bi_db_destroy) ? ov->db.bd_info->bi_db_destroy(&ov->db) : 0;
+               /* cleanup stuff inherited from the original database... */
+               ov->db.be_suffix = NULL;
+               ov->db.be_nsuffix = NULL;
+               BER_BVZERO( &ov->db.be_rootdn );
+               BER_BVZERO( &ov->db.be_rootndn );
+               BER_BVZERO( &ov->db.be_rootpw );
+               /* FIXME: there might be more... */
+
+               if ( ov->db.be_private != NULL ) {
+                       backend_destroy_one( &ov->db, 0 );
+               }
+
                ch_free(ov);
                on->on_bi.bi_private = NULL;
        }