From: Jong Hyuk Choi Date: Tue, 14 Sep 2004 01:03:08 +0000 (+0000) Subject: referral mem leak fix X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~532 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=86aa3728b9c241dad65331ebe0daa8073ff0865c;p=openldap referral mem leak fix --- diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 80452ddd1f..80dfedaa74 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -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; diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 1115cdd7c9..f5c77763c3 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -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; diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 59dcc88b7a..d234353ae3 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -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; diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 6199191855..81358859bf 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -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; diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 4f9a79706a..4754cf3c09 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -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; diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index a76c7874d3..5a6229f1bf 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -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;