From: Kevin H. Patterson Date: Wed, 26 Feb 2014 18:08:24 +0000 (-0500) Subject: ITS#7806 fixed memory leak in LDAPAsynConnection.cpp X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5791cc46a4fc9cd6f0726113d97f33182db23808;p=openldap ITS#7806 fixed memory leak in LDAPAsynConnection.cpp --- diff --git a/contrib/ldapc++/src/LDAPAsynConnection.cpp b/contrib/ldapc++/src/LDAPAsynConnection.cpp index 894f8ba205..582d2b53ae 100644 --- a/contrib/ldapc++/src/LDAPAsynConnection.cpp +++ b/contrib/ldapc++/src/LDAPAsynConnection.cpp @@ -43,7 +43,10 @@ LDAPAsynConnection::LDAPAsynConnection(const string& url, int port, this->setConstraints(cons); } -LDAPAsynConnection::~LDAPAsynConnection(){} +LDAPAsynConnection::~LDAPAsynConnection(){ + unbind(); + delete m_constr; +} void LDAPAsynConnection::init(const string& hostname, int port){ DEBUG(LDAP_DEBUG_TRACE,"LDAPAsynConnection::init" << endl); @@ -51,6 +54,8 @@ void LDAPAsynConnection::init(const string& hostname, int port){ " hostname:" << hostname << endl << " port:" << port << endl); + unbind(); + m_uri.setScheme("ldap"); m_uri.setHost(hostname); m_uri.setPort(port); @@ -66,6 +71,8 @@ void LDAPAsynConnection::init(const string& hostname, int port){ } void LDAPAsynConnection::initialize(const std::string& uri){ + unbind(); + m_uri.setURLString(uri); int ret = ldap_initialize(&cur_session, m_uri.getURLString().c_str()); if ( ret != LDAP_SUCCESS ) { @@ -277,6 +284,7 @@ void LDAPAsynConnection::unbind(){ void LDAPAsynConnection::setConstraints(LDAPConstraints *cons){ DEBUG(LDAP_DEBUG_TRACE,"LDAPAsynConnection::setConstraints()" << endl); + delete m_constr; m_constr=cons; }