[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Bug fix: memory leaking in libraries/libldap/open.c (ITS#1125)



I applied a fix based upon your suggestion to
OPENLDAP_REL_ENG_1_2.  Please test, thanks, Kurt


At 06:58 AM 4/24/01, Dmitri.Belotchkine@AtosOrigin.com wrote:
>Hi,
>
>There is memory leaking in ver. 1.2.11 when connection to LDAP server is
>failed.
>The problem is in libraries/libldap/open.c:
>
>The leaking occurs in the following function:
>
>LDAP *
>ldap_open( char *host, int port )
>{
>        LDAP            *ld;
>#ifdef LDAP_REFERRALS
>        LDAPServer      *srv;
>#endif /* LDAP_REFERRALS */
>
>        Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
>
>        if (( ld = ldap_init( host, port )) == NULL ) {
>                return( NULL );
>        }
>
>        if ( ldap_delayed_open( ld ) < 0 ) {
>                return( NULL );
>        }
>
>        Debug( LDAP_DEBUG_TRACE, "ldap_open successful, ld_host is
>%s\n",
>                ( ld->ld_host == NULL ) ? "(null)" : ld->ld_host, 0, 0
>);
>
>        return( ld );
>}
>
>After successfull ldap_init memory allocated to ld and this memory leaks
>after unsuccessfull ldap_delayed_open.
>If to implement:
>
>        if ( ldap_delayed_open( ld ) < 0 ) {
>
>/* Add this to avoid memory leaking */
>                 if ( ld != NULL ) ldap_ld_free( ld, 0 );
>/* ------------------------------------------*/
>
>                return( NULL );
>        }
>
>then everything is gonna be ok.
>
>Best regards,
>
>--
>Dmitri Belotchkine
>Operations Development Engineer
>AtosOrigin - eBusiness - Unix Application & Hosting Services
>Phone: +31 (0)40 2789381