From 5568abbbcabcc4f71fc30ce2247f30d69b0db356 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 27 Mar 2008 14:02:58 +0000 Subject: [PATCH] - Plugged memory leak default constructor - Fixed copy-constructor --- contrib/ldapc++/src/LDAPEntry.cpp | 14 ++++++++++++-- contrib/ldapc++/src/LDAPEntry.h | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/contrib/ldapc++/src/LDAPEntry.cpp b/contrib/ldapc++/src/LDAPEntry.cpp index 6084b10088..1052cb5e1b 100644 --- a/contrib/ldapc++/src/LDAPEntry.cpp +++ b/contrib/ldapc++/src/LDAPEntry.cpp @@ -22,8 +22,11 @@ LDAPEntry::LDAPEntry(const LDAPEntry& entry){ LDAPEntry::LDAPEntry(const string& dn, const LDAPAttributeList *attrs){ DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl); DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, - " dn:" << dn << endl << " attrs:" << *attrs << endl); - m_attrs=new LDAPAttributeList(*attrs); + " dn:" << dn << endl); + if ( attrs ) + m_attrs=new LDAPAttributeList(*attrs); + else + m_attrs=new LDAPAttributeList(); m_dn=dn; } @@ -40,6 +43,13 @@ LDAPEntry::~LDAPEntry(){ delete m_attrs; } +LDAPEntry& LDAPEntry::operator=(const LDAPEntry& from){ + m_dn = from.m_dn; + delete m_attrs; + m_attrs = new LDAPAttributeList( *(from.m_attrs)); + return *this; +} + void LDAPEntry::setDN(const string& dn){ DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::setDN()" << endl); DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER, diff --git a/contrib/ldapc++/src/LDAPEntry.h b/contrib/ldapc++/src/LDAPEntry.h index a385b17718..574e44695f 100644 --- a/contrib/ldapc++/src/LDAPEntry.h +++ b/contrib/ldapc++/src/LDAPEntry.h @@ -30,7 +30,7 @@ class LDAPEntry{ * @param attrs The attributes for the new entry. */ LDAPEntry(const std::string& dn=std::string(), - const LDAPAttributeList *attrs=new LDAPAttributeList()); + const LDAPAttributeList *attrs=0); /** * Used internally only. @@ -44,7 +44,12 @@ class LDAPEntry{ * Destructor */ ~LDAPEntry(); - + + /** + * Assingment operator + */ + LDAPEntry& operator=(const LDAPEntry& from); + /** * Sets the DN-attribute. * @param dn: The new DN for the entry. -- 2.39.2