]> git.sur5r.net Git - openldap/commitdiff
plugged one time memory leak (found with valgrind)
authorRalf Haferkamp <ralf@openldap.org>
Fri, 22 Jan 2010 18:01:25 +0000 (18:01 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Fri, 22 Jan 2010 18:01:25 +0000 (18:01 +0000)
servers/slapd/overlays/sssvlv.c

index 5c82b91212aef88870978452e6c317747de7e90e..0ee623da4fab9255880b7136eed73f3c592937c1 100644 (file)
@@ -113,6 +113,7 @@ typedef struct sort_op
 /* There is only one conn table for all overlay instances */
 static sort_op **sort_conns;
 static ldap_pvt_thread_mutex_t sort_conns_mutex;
+static int ov_count;
 static const char *debug_header = "sssvlv";
 
 static int sss_cid;
@@ -1165,6 +1166,7 @@ static int sssvlv_db_init(
                sort_conns = ch_calloc( sizeof(sort_op *), dtblsize + 1 );
                sort_conns++;
        }
+       ov_count++;
 
        return LDAP_SUCCESS;
 }
@@ -1176,6 +1178,13 @@ static int sssvlv_db_destroy(
        slap_overinst   *on = (slap_overinst *)be->bd_info;
        sssvlv_info *si = (sssvlv_info *)on->on_bi.bi_private;
        
+       ov_count--;
+       if ( !ov_count && sort_conns) {
+               sort_conns--;
+               ch_free(sort_conns);
+               ldap_pvt_thread_mutex_destroy( &sort_conns_mutex );
+       }
+       
        if ( si ) {
                ch_free( si );
                on->on_bi.bi_private = NULL;