]> git.sur5r.net Git - openldap/commitdiff
referral mem leak fix
authorJong Hyuk Choi <jongchoi@openldap.org>
Tue, 14 Sep 2004 01:03:08 +0000 (01:03 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Tue, 14 Sep 2004 01:03:08 +0000 (01:03 +0000)
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/modrdn.c

index 80452ddd1fbb5fd25f89f2b228afc98093b55203..80dfedaa74eb4fb0c90dd102d2ef342ba665d1df 100644 (file)
@@ -142,6 +142,8 @@ retry:      /* transaction retry */
 
        /* FIXME : dn2entry() should return non-glue entry */
        if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) {
+               BerVarray deref = NULL;
+
                Debug( LDAP_DEBUG_ARGS,
                        "<=- bdb_delete: no such object %s\n",
                        op->o_req_dn.bv_val, 0, 0);
@@ -155,7 +157,6 @@ retry:      /* transaction retry */
                        matched = NULL;
 
                } else {
-                       BerVarray deref = NULL;
                        if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                syncinfo_t *si;
                                LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
@@ -167,7 +168,7 @@ retry:      /* transaction retry */
                                deref = default_referral;
                        }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                               LDAP_SCOPE_DEFAULT );
+                                       LDAP_SCOPE_DEFAULT );
                }
 
                rs->sr_err = LDAP_REFERRAL;
@@ -176,6 +177,9 @@ retry:      /* transaction retry */
                if ( rs->sr_ref != default_referral ) {
                        ber_bvarray_free( rs->sr_ref );
                }
+               if ( deref != default_referral ) {
+                       ber_bvarray_free( deref );
+               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
index 1115cdd7c98aca2613a03dad83360b42dbd94967..f5c77763c39601c343f852076df80f5595f5b9ea 100644 (file)
@@ -381,6 +381,7 @@ retry:      /* transaction retry */
        if (( rs->sr_err == DB_NOTFOUND ) ||
                ( !manageDSAit && e && is_entry_glue( e )))
        {
+               BerVarray deref = NULL;
                if ( e != NULL ) {
                        rs->sr_matched = ch_strdup( e->e_dn );
                        rs->sr_ref = is_entry_referral( e )
@@ -390,7 +391,6 @@ retry:      /* transaction retry */
                        e = NULL;
 
                } else {
-                       BerVarray deref = NULL;
                        if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                syncinfo_t *si;
                                LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
@@ -402,7 +402,7 @@ retry:      /* transaction retry */
                                deref = default_referral;
                        }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                               LDAP_SCOPE_DEFAULT );
+                                       LDAP_SCOPE_DEFAULT );
                }
 
                rs->sr_err = LDAP_REFERRAL;
@@ -411,6 +411,9 @@ retry:      /* transaction retry */
                if ( rs->sr_ref != default_referral ) {
                        ber_bvarray_free( rs->sr_ref );
                }
+               if ( deref != default_referral ) {
+                       ber_bvarray_free( deref );
+               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
index 59dcc88b7a65ccaae850575f74b61785a0ad573e..d234353ae341366291fe95faf08b88a241b70391 100644 (file)
@@ -170,6 +170,7 @@ retry:      /* transaction retry */
        if (( rs->sr_err == DB_NOTFOUND ) ||
                ( !manageDSAit && e && is_entry_glue( e )))
        {
+               BerVarray deref = NULL;
                if( e != NULL ) {
                        rs->sr_matched = ch_strdup( e->e_dn );
                        rs->sr_ref = is_entry_referral( e )
@@ -179,7 +180,6 @@ retry:      /* transaction retry */
                        e = NULL;
 
                } else {
-                       BerVarray deref = NULL;
                        if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                syncinfo_t *si;
                                LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
@@ -191,13 +191,16 @@ retry:    /* transaction retry */
                                deref = default_referral;
                        }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                               LDAP_SCOPE_DEFAULT );
+                                       LDAP_SCOPE_DEFAULT );
                }
 
                rs->sr_err = LDAP_REFERRAL;
                send_ldap_result( op, rs );
 
                ber_bvarray_free( rs->sr_ref );
+               if ( deref != default_referral ) {
+                       ber_bvarray_free( deref );
+               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
index 619919185588a09f67628a634bf2d075280c9245..81358859bf89d13d9410f24774a950cb738dcd55 100644 (file)
@@ -49,6 +49,8 @@ ldbm_back_delete(
 
        /* FIXME : dn2entry() should return non-glue entry */
        if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) {
+               BerVarray deref = NULL;
+
                Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: no such object %s\n",
                        op->o_req_dn.bv_val, 0, 0);
 
@@ -60,7 +62,6 @@ ldbm_back_delete(
                        cache_return_entry_r( &li->li_cache, matched );
 
                } else {
-                       BerVarray deref = NULL;
                        if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                syncinfo_t *si;
                                LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
@@ -72,7 +73,7 @@ ldbm_back_delete(
                                deref = default_referral;
                        }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                                               LDAP_SCOPE_DEFAULT );
+                                                       LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -81,6 +82,9 @@ ldbm_back_delete(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
+               if ( deref != default_referral ) {
+                       ber_bvarray_free( deref );
+               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
index 4f9a79706a585c2f9c7d69d5fc64d81855fcf9cf..4754cf3c09d6529c5e96959944fae236f9693775 100644 (file)
@@ -249,6 +249,7 @@ ldbm_back_modify(
 
        /* FIXME: dn2entry() should return non-glue entry */
        if (( e == NULL ) || ( !manageDSAit && e && is_entry_glue( e ))) {
+               BerVarray deref = NULL;
                if ( matched != NULL ) {
                        rs->sr_matched = ch_strdup( matched->e_dn );
                        rs->sr_ref = is_entry_referral( matched )
@@ -256,7 +257,6 @@ ldbm_back_modify(
                                : NULL;
                        cache_return_entry_r( &li->li_cache, matched );
                } else {
-                       BerVarray deref = NULL;
                        if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                syncinfo_t *si;
                                LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
@@ -268,7 +268,7 @@ ldbm_back_modify(
                                deref = default_referral;
                        }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                                       LDAP_SCOPE_DEFAULT );
+                                               LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -276,6 +276,9 @@ ldbm_back_modify(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
+               if ( deref != default_referral ) {
+                       ber_bvarray_free( deref );
+               }
                free( (char *)rs->sr_matched );
 
                rs->sr_ref = NULL;
index a76c7874d31ff393feb2706764d167367d49d2e0..5a6229f1bf7e46ddf2a03cd3bf6b15e9c7fa3a80 100644 (file)
@@ -77,6 +77,7 @@ ldbm_back_modrdn(
        /* get entry with writer lock */
        /* FIXME: dn2entry() should return non-glue entry */
        if (( e == NULL  ) || ( !manageDSAit && e && is_entry_glue( e ))) {
+               BerVarray deref = NULL;
                if ( matched != NULL ) {
                        rs->sr_matched = strdup( matched->e_dn );
                        rs->sr_ref = is_entry_referral( matched )
@@ -84,7 +85,6 @@ ldbm_back_modrdn(
                                : NULL;
                        cache_return_entry_r( &li->li_cache, matched );
                } else {
-                       BerVarray deref = NULL;
                        if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                syncinfo_t *si;
                                LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
@@ -96,7 +96,7 @@ ldbm_back_modrdn(
                                deref = default_referral;
                        }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                                                       LDAP_SCOPE_DEFAULT );
+                                               LDAP_SCOPE_DEFAULT );
                }
 
                ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -105,6 +105,9 @@ ldbm_back_modrdn(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
+               if ( deref != default_referral ) {
+                       ber_bvarray_free( deref );
+               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;