]> git.sur5r.net Git - openldap/commitdiff
ITS#5094 fix from HEAD
authorHoward Chu <hyc@openldap.org>
Thu, 16 Aug 2007 20:49:56 +0000 (20:49 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 16 Aug 2007 20:49:56 +0000 (20:49 +0000)
servers/slapd/overlays/ppolicy.c

index 2c68c9d0afa5bfbb9a619fddcb47d66b8c54cc33..0046310e807df3a415e257eaab6fa4a4d5e942f4 100644 (file)
@@ -61,6 +61,7 @@ typedef struct pw_conn {
 
 static pw_conn *pwcons;
 static int ppolicy_cid;
+static int ov_count;
 
 typedef struct pass_policy {
        AttributeDescription *ad; /* attribute to which the policy applies */
@@ -2118,6 +2119,7 @@ ppolicy_db_open(
     BackendDB *be
 )
 {
+       ov_count++;
        return overlay_register_control( be, LDAP_CONTROL_PASSWORDPOLICYREQUEST );
 }
 
@@ -2128,8 +2130,13 @@ ppolicy_close(
 {
        slap_overinst *on = (slap_overinst *) be->bd_info;
        pp_info *pi = on->on_bi.bi_private;
-       
-       free( pwcons );
+
+       /* Perhaps backover should provide bi_destroy hooks... */
+       ov_count--;
+       if ( ov_count <=0 && pwcons ) {
+               free( pwcons );
+               pwcons = NULL;
+       }
        free( pi->def_policy.bv_val );
        free( pi );