]> git.sur5r.net Git - openldap/commitdiff
Fix one time memory leak
authorQuanah Gibson-Mount <quanah@openldap.org>
Wed, 14 Apr 2010 19:56:50 +0000 (19:56 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 14 Apr 2010 19:56:50 +0000 (19:56 +0000)
servers/slapd/overlays/sssvlv.c

index 7dc3dab8e218761b9d5ca7e48267ec56aaff692b..c69886cb7dd7c47a0be1d61a76e382324a9d9061 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;