From: Kurt Zeilenga Date: Thu, 26 Aug 1999 19:12:15 +0000 (+0000) Subject: Use NULL pointer to indicate values need not be freed instead of X-Git-Tag: TWEB_OL_BASE~103 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=60033b38ace3d51071f670b8e7404f14f69e7905;p=openldap Use NULL pointer to indicate values need not be freed instead of relying on developer selecting the right goto label. --- diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 4120263fa4..d07f68021e 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -271,14 +271,6 @@ ldbm_back_modrdn( "ldbm_back_modrdn: new ndn=%s does not exist\n", new_ndn, 0, 0 ); - /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); - if ( op->o_abandon ) { - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - goto return_results; - } - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - /* Get attribute type and attribute value of our new rdn, we will * need to add that to our new entry */ @@ -417,6 +409,14 @@ ldbm_back_modrdn( } #endif + /* check for abandon */ + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); + if ( op->o_abandon ) { + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + goto return_results; + } + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + /* delete old one */ if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, @@ -425,10 +425,15 @@ ldbm_back_modrdn( } (void) cache_delete_entry( &li->li_cache, e ); + + /* XXX: there is no going back! */ + free( e->e_dn ); free( e->e_ndn ); e->e_dn = new_dn; e->e_ndn = new_ndn; + new_dn = NULL; + new_ndn = NULL; /* add new one */ if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) { @@ -437,7 +442,6 @@ ldbm_back_modrdn( goto return_results; } - /* modify memory copy of entry */ if ( ldbm_modify_internal( be, conn, op, dn, &mod[0], e ) != 0 ) { @@ -456,23 +460,17 @@ ldbm_back_modrdn( entry_free( e ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL, NULL, NULL ); - goto return_results_after; + goto return_results; } send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL ); rc = 0; - goto return_results_after; return_results: if( new_dn != NULL ) free( new_dn ); if( new_ndn != NULL ) free( new_ndn ); -return_results_after: - /* NOTE: - * new_dn and new_ndn are not deallocated because they are used by - * the cache entry. - */ if( p_dn != NULL ) free( p_dn ); if( p_ndn != NULL ) free( p_ndn );