From 8d57c9fe456ff8d0246363519670d592f41e9be7 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Wed, 14 Nov 2001 17:33:54 +0000 Subject: [PATCH] Fixed some memory allocation/freeing bugs --- contrib/ldapc++/src/LDAPAddRequest.cpp | 4 +- contrib/ldapc++/src/LDAPAsynConnection.cpp | 4 +- contrib/ldapc++/src/LDAPAttribute.cpp | 52 +++++++++++----------- contrib/ldapc++/src/LDAPAttributeList.cpp | 2 +- contrib/ldapc++/src/LDAPBindRequest.cpp | 8 ++-- contrib/ldapc++/src/LDAPCompareRequest.cpp | 4 +- contrib/ldapc++/src/LDAPControl.cpp | 7 +++ contrib/ldapc++/src/LDAPControl.h | 3 +- contrib/ldapc++/src/LDAPControlSet.cpp | 9 ++++ contrib/ldapc++/src/LDAPControlSet.h | 2 +- contrib/ldapc++/src/LDAPDeleteRequest.cpp | 4 +- contrib/ldapc++/src/LDAPEntry.cpp | 2 +- contrib/ldapc++/src/LDAPExtRequest.cpp | 8 ++-- contrib/ldapc++/src/LDAPMessageQueue.cpp | 10 ++--- contrib/ldapc++/src/LDAPModDNRequest.cpp | 4 +- contrib/ldapc++/src/LDAPModList.cpp | 17 +++---- contrib/ldapc++/src/LDAPModification.cpp | 34 +++++++------- contrib/ldapc++/src/LDAPModifyRequest.cpp | 5 ++- contrib/ldapc++/src/LDAPResult.cpp | 4 +- contrib/ldapc++/src/LDAPSearchRequest.cpp | 4 +- contrib/ldapc++/src/StringList.cpp | 4 +- 21 files changed, 105 insertions(+), 86 deletions(-) diff --git a/contrib/ldapc++/src/LDAPAddRequest.cpp b/contrib/ldapc++/src/LDAPAddRequest.cpp index 0cad59ec11..b3a1a4d099 100644 --- a/contrib/ldapc++/src/LDAPAddRequest.cpp +++ b/contrib/ldapc++/src/LDAPAddRequest.cpp @@ -50,8 +50,8 @@ LDAPMessageQueue* LDAPAddRequest::sendRequest(){ LDAPControl** tmpClCtrls = m_cons->getClCtrlsArray(); int err=ldap_add_ext(m_connection->getSessionHandle(), m_entry->getDN().c_str(),attrs,tmpSrvCtrls,tmpClCtrls,&msgID); - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); ldap_mods_free(attrs,1); if(err != LDAP_SUCCESS){ throw LDAPException(err); diff --git a/contrib/ldapc++/src/LDAPAsynConnection.cpp b/contrib/ldapc++/src/LDAPAsynConnection.cpp index 095061d676..2c1be7a299 100644 --- a/contrib/ldapc++/src/LDAPAsynConnection.cpp +++ b/contrib/ldapc++/src/LDAPAsynConnection.cpp @@ -211,8 +211,8 @@ void LDAPAsynConnection::unbind(){ LDAPControl** tmpClCtrls=m_constr->getClCtrlsArray(); int err=ldap_unbind_ext(cur_session, tmpSrvCtrls, tmpClCtrls); cur_session=0; - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); if(err != LDAP_SUCCESS){ throw LDAPException(err); } diff --git a/contrib/ldapc++/src/LDAPAttribute.cpp b/contrib/ldapc++/src/LDAPAttribute.cpp index d591402417..6671414344 100644 --- a/contrib/ldapc++/src/LDAPAttribute.cpp +++ b/contrib/ldapc++/src/LDAPAttribute.cpp @@ -123,18 +123,18 @@ const StringList& LDAPAttribute::getValues() const{ BerValue** LDAPAttribute::getBerValues() const{ DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::getBerValues()" << endl); - size_t size=m_values.size(); + size_t size=m_values.size(); if (size == 0){ return 0; }else{ - BerValue **temp = new BerValue*[size+1]; + BerValue **temp = (BerValue**) malloc(sizeof(BerValue*) * (size+1)); StringList::const_iterator i; int p=0; for(i=m_values.begin(), p=0; i!=m_values.end(); i++,p++){ - temp[p]=new BerValue; + temp[p]=(BerValue*) malloc(sizeof(BerValue)); temp[p]->bv_len= i->size(); - temp[p]->bv_val= new char[i->size()+1]; + temp[p]->bv_val= (char*) malloc(sizeof(char) * (i->size()+1)); i->copy(temp[p]->bv_val,string::npos); } temp[size]=0; @@ -162,37 +162,37 @@ void LDAPAttribute::setName(const string& name){ // The bin-FLAG of the mod_op is always set to LDAP_MOD_BVALUES (0x80) LDAPMod* LDAPAttribute::toLDAPMod() const { DEBUG(LDAP_DEBUG_TRACE, "LDAPAttribute::toLDAPMod()" << endl); - LDAPMod* ret=new LDAPMod(); - ret->mod_op=LDAP_MOD_BVALUES; //always assume binary-Values - ret->mod_type= new char[m_name.size()+1]; + LDAPMod* ret= (LDAPMod*) malloc(sizeof(LDAPMod)); + ret->mod_op=LDAP_MOD_BVALUES; //always assume binary-Values + ret->mod_type= (char*) malloc(sizeof(char) * (m_name.size()+1)); m_name.copy(ret->mod_type,string::npos); ret->mod_type[m_name.size()]=0; - ret->mod_bvalues=this->getBerValues(); - return ret; + ret->mod_bvalues=this->getBerValues(); + return ret; } bool LDAPAttribute::isNotPrintable() const { - StringList::const_iterator i; - for(i=m_values.begin(); i!=m_values.end(); i++){ - size_t len = i->size(); - for(size_t j=0; jdata())[j] ) ){ - return true; - } - } + StringList::const_iterator i; + for(i=m_values.begin(); i!=m_values.end(); i++){ + size_t len = i->size(); + for(size_t j=0; jdata())[j] ) ){ + return true; + } } - return false; + } + return false; } ostream& operator << (ostream& s, const LDAPAttribute& attr){ - s << attr.m_name << "="; - StringList::const_iterator i; - if (attr.isNotPrintable()){ - s << "NOT_PRINTABLE" ; - }else{ - for(i=attr.m_values.begin(); i!=attr.m_values.end(); i++){ - s << *i << " "; - } + s << attr.m_name << "="; + StringList::const_iterator i; + if (attr.isNotPrintable()){ + s << "NOT_PRINTABLE" ; + }else{ + for(i=attr.m_values.begin(); i!=attr.m_values.end(); i++){ + s << *i << " "; } + } return s; } diff --git a/contrib/ldapc++/src/LDAPAttributeList.cpp b/contrib/ldapc++/src/LDAPAttributeList.cpp index 94881b70ec..7c26ef3ec5 100644 --- a/contrib/ldapc++/src/LDAPAttributeList.cpp +++ b/contrib/ldapc++/src/LDAPAttributeList.cpp @@ -92,7 +92,7 @@ void LDAPAttributeList::addAttribute(const LDAPAttribute& attr){ LDAPMod** LDAPAttributeList::toLDAPModArray() const{ DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::toLDAPModArray()" << endl); - LDAPMod **ret = new LDAPMod*[m_attrs.size()+1]; + LDAPMod **ret = (LDAPMod**) malloc((m_attrs.size()+1) * sizeof(LDAPMod*)); AttrList::const_iterator i; int j=0; for (i=m_attrs.begin(); i!= m_attrs.end(); i++, j++){ diff --git a/contrib/ldapc++/src/LDAPBindRequest.cpp b/contrib/ldapc++/src/LDAPBindRequest.cpp index ca5b75a571..28d0cf6821 100644 --- a/contrib/ldapc++/src/LDAPBindRequest.cpp +++ b/contrib/ldapc++/src/LDAPBindRequest.cpp @@ -42,12 +42,12 @@ LDAPMessageQueue* LDAPBindRequest::sendRequest(){ const char* mech = (m_mech == "" ? 0 : m_mech.c_str()); BerValue* tmpcred=0; if(m_cred != ""){ - char* tmppwd = new char[m_cred.size()+1]; + char* tmppwd = (char*) malloc( (m_cred.size()+1) * sizeof(char)); m_cred.copy(tmppwd,string::npos); tmppwd[m_cred.size()]=0; tmpcred=ber_bvstr(tmppwd); }else{ - tmpcred=new BerValue; + tmpcred=(BerValue*) malloc(sizeof(BerValue)); tmpcred->bv_len=0; tmpcred->bv_val=0; } @@ -59,8 +59,8 @@ LDAPMessageQueue* LDAPBindRequest::sendRequest(){ LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray(); int err=ldap_sasl_bind(m_connection->getSessionHandle(),dn, mech, tmpcred, tmpSrvCtrls, tmpClCtrls, &msgID); - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); ber_bvfree(tmpcred); if(err != LDAP_SUCCESS){ diff --git a/contrib/ldapc++/src/LDAPCompareRequest.cpp b/contrib/ldapc++/src/LDAPCompareRequest.cpp index 7e6a731a94..048c9d1e7b 100644 --- a/contrib/ldapc++/src/LDAPCompareRequest.cpp +++ b/contrib/ldapc++/src/LDAPCompareRequest.cpp @@ -50,8 +50,8 @@ LDAPMessageQueue* LDAPCompareRequest::sendRequest(){ m_attr.getName().c_str(), val[0], tmpSrvCtrls, tmpClCtrls, &msgID); ber_bvecfree(val); - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); if(err != LDAP_SUCCESS){ throw LDAPException(err); }else{ diff --git a/contrib/ldapc++/src/LDAPControl.cpp b/contrib/ldapc++/src/LDAPControl.cpp index 073191cfa5..6e7c94bb92 100644 --- a/contrib/ldapc++/src/LDAPControl.cpp +++ b/contrib/ldapc++/src/LDAPControl.cpp @@ -79,3 +79,10 @@ LDAPControl* LDAPCtrl::getControlStruct() const { return ret; } +void LDAPCtrl::freeLDAPControlStruct(LDAPControl *ctrl){ + DEBUG(LDAP_DEBUG_TRACE,"LDAPCtrl::freeControlStruct()" << endl); + delete[] ctrl->ldctl_oid; + delete[] ctrl->ldctl_value.bv_val; + delete ctrl; +} + diff --git a/contrib/ldapc++/src/LDAPControl.h b/contrib/ldapc++/src/LDAPControl.h index 38c5ce50b5..bdec5c3bfb 100644 --- a/contrib/ldapc++/src/LDAPControl.h +++ b/contrib/ldapc++/src/LDAPControl.h @@ -73,7 +73,8 @@ class LDAPCtrl{ * the C-API */ LDAPControl* getControlStruct() const; - + static void freeLDAPControlStruct(LDAPControl *ctrl); + private : std::string m_oid; std::string m_data; diff --git a/contrib/ldapc++/src/LDAPControlSet.cpp b/contrib/ldapc++/src/LDAPControlSet.cpp index 53d8496046..9f62363c48 100644 --- a/contrib/ldapc++/src/LDAPControlSet.cpp +++ b/contrib/ldapc++/src/LDAPControlSet.cpp @@ -72,3 +72,12 @@ LDAPControl** LDAPControlSet::toLDAPControlArray() const{ } } +void LDAPControlSet::freeLDAPControlArray(LDAPControl **ctrl){ + DEBUG(LDAP_DEBUG_TRACE, "LDAPControlSet::freeLDAPControlArray()" << endl); + if( ctrl ){ + for( LDAPControl **i = ctrl; *i != 0; ++i ){ + LDAPCtrl::freeLDAPControlStruct(*i); + } + } + delete[] ctrl; +} diff --git a/contrib/ldapc++/src/LDAPControlSet.h b/contrib/ldapc++/src/LDAPControlSet.h index 353d939e98..82b4649e29 100644 --- a/contrib/ldapc++/src/LDAPControlSet.h +++ b/contrib/ldapc++/src/LDAPControlSet.h @@ -81,7 +81,7 @@ class LDAPControlSet { * LDAPControl-structures as needed by the C-API */ LDAPControl** toLDAPControlArray()const ; - + static void freeLDAPControlArray(LDAPControl **ctrl); private : CtrlList data; } ; diff --git a/contrib/ldapc++/src/LDAPDeleteRequest.cpp b/contrib/ldapc++/src/LDAPDeleteRequest.cpp index bad6adcdfe..e6fbb251b0 100644 --- a/contrib/ldapc++/src/LDAPDeleteRequest.cpp +++ b/contrib/ldapc++/src/LDAPDeleteRequest.cpp @@ -47,8 +47,8 @@ LDAPMessageQueue* LDAPDeleteRequest::sendRequest(){ LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray(); int err=ldap_delete_ext(m_connection->getSessionHandle(),m_dn.c_str(), tmpSrvCtrls, tmpClCtrls ,&msgID); - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); if(err != LDAP_SUCCESS){ throw LDAPException(err); }else{ diff --git a/contrib/ldapc++/src/LDAPEntry.cpp b/contrib/ldapc++/src/LDAPEntry.cpp index 325e2a4e50..3af69cc593 100644 --- a/contrib/ldapc++/src/LDAPEntry.cpp +++ b/contrib/ldapc++/src/LDAPEntry.cpp @@ -30,7 +30,7 @@ LDAPEntry::LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg){ DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl); char* tmp=ldap_get_dn(ld->getSessionHandle(),msg); m_dn=string(tmp); - delete[] tmp; + free(tmp); m_attrs = new LDAPAttributeList(ld, msg); } diff --git a/contrib/ldapc++/src/LDAPExtRequest.cpp b/contrib/ldapc++/src/LDAPExtRequest.cpp index 18b0f42aeb..b7f54eeecd 100644 --- a/contrib/ldapc++/src/LDAPExtRequest.cpp +++ b/contrib/ldapc++/src/LDAPExtRequest.cpp @@ -41,17 +41,17 @@ LDAPMessageQueue* LDAPExtRequest::sendRequest(){ int msgID=0; BerValue* tmpdata=0; if(m_data != ""){ - tmpdata=new BerValue; + tmpdata=(BerValue*) malloc(sizeof(BerValue)); tmpdata->bv_len = m_data.size(); - tmpdata->bv_val = new char[m_data.size()]; + tmpdata->bv_val = (char*) malloc(sizeof(char) * (m_data.size()) ); m_data.copy(tmpdata->bv_val, string::npos); } LDAPControl** tmpSrvCtrls=m_cons->getSrvCtrlsArray(); LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray(); int err=ldap_extended_operation(m_connection->getSessionHandle(), m_oid.c_str(), tmpdata, tmpSrvCtrls, tmpClCtrls, &msgID); - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); ber_bvfree(tmpdata); if(err != LDAP_SUCCESS){ delete this; diff --git a/contrib/ldapc++/src/LDAPMessageQueue.cpp b/contrib/ldapc++/src/LDAPMessageQueue.cpp index cf5bb0d805..2668609e87 100644 --- a/contrib/ldapc++/src/LDAPMessageQueue.cpp +++ b/contrib/ldapc++/src/LDAPMessageQueue.cpp @@ -41,18 +41,18 @@ LDAPMessageQueue::~LDAPMessageQueue(){ LDAPMsg *LDAPMessageQueue::getNext(){ DEBUG(LDAP_DEBUG_TRACE,"LDAPMessageQueue::getNext()" << endl); - LDAPMessage *msg; + LDAPMessage *msg; LDAPRequest *req=m_activeReq.top(); int msg_id = req->getMsgID(); - int res; + int res; const LDAPAsynConnection *con=req->getConnection(); res=ldap_result(con->getSessionHandle(),msg_id,0,0,&msg); if (res <= 0){ if(msg != 0){ ldap_msgfree(msg); } - throw LDAPException(con); - }else{ + throw LDAPException(con); + }else{ const LDAPConstraints *constr=req->getConstraints(); LDAPMsg *ret=0; //this can throw an exception (Decoding Error) @@ -144,7 +144,7 @@ LDAPMsg *LDAPMessageQueue::getNext(){ } break; } - } + } } // TODO Maybe moved to LDAPRequest::followReferral seems more reasonable diff --git a/contrib/ldapc++/src/LDAPModDNRequest.cpp b/contrib/ldapc++/src/LDAPModDNRequest.cpp index 44f4aaadb7..0d96437079 100644 --- a/contrib/ldapc++/src/LDAPModDNRequest.cpp +++ b/contrib/ldapc++/src/LDAPModDNRequest.cpp @@ -60,8 +60,8 @@ LDAPMessageQueue* LDAPModDNRequest::sendRequest(){ LDAPControl** tmpClCtrls=m_cons->getClCtrlsArray(); int err=ldap_rename(m_connection->getSessionHandle(),m_dn.c_str(),newRDN, newParentDN,m_deleteOld ? 1 : 0, tmpSrvCtrls, tmpClCtrls,&msg_id); - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); if(err!=LDAP_SUCCESS){ throw LDAPException(err); }else{ diff --git a/contrib/ldapc++/src/LDAPModList.cpp b/contrib/ldapc++/src/LDAPModList.cpp index 5b0ae9b12e..d8bed4f685 100644 --- a/contrib/ldapc++/src/LDAPModList.cpp +++ b/contrib/ldapc++/src/LDAPModList.cpp @@ -25,12 +25,13 @@ void LDAPModList::addModification(const LDAPModification &mod){ LDAPMod** LDAPModList::toLDAPModArray(){ DEBUG(LDAP_DEBUG_TRACE,"LDAPModList::toLDAPModArray()" << endl); - LDAPMod **ret = new LDAPMod*[m_modList.size()+1]; - ret[m_modList.size()]=0; - ModList::const_iterator i; - int j=0; - for (i=m_modList.begin(); i != m_modList.end(); i++ , j++){ - ret[j]=i->toLDAPMod(); - } - return ret; + LDAPMod **ret = (LDAPMod**) malloc( + (m_modList.size()+1) * sizeof(LDAPMod*)); + ret[m_modList.size()]=0; + ModList::const_iterator i; + int j=0; + for (i=m_modList.begin(); i != m_modList.end(); i++ , j++){ + ret[j]=i->toLDAPMod(); + } + return ret; } diff --git a/contrib/ldapc++/src/LDAPModification.cpp b/contrib/ldapc++/src/LDAPModification.cpp index cab3176f08..9693852753 100644 --- a/contrib/ldapc++/src/LDAPModification.cpp +++ b/contrib/ldapc++/src/LDAPModification.cpp @@ -13,27 +13,27 @@ LDAPModification::LDAPModification(const LDAPAttribute& attr, mod_op op){ DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPModification::LDAPModification()" << endl); DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER, " attr:" << attr << endl); - m_attr = attr; - m_mod_op = op; + m_attr = attr; + m_mod_op = op; } LDAPMod* LDAPModification::toLDAPMod() const { DEBUG(LDAP_DEBUG_TRACE,"LDAPModification::toLDAPMod()" << endl); - LDAPMod* ret=m_attr.toLDAPMod(); + LDAPMod* ret=m_attr.toLDAPMod(); - //The mod_op value of the LDAPMod-struct needs to be ORed with the right - // LDAP_MOD_* constant to preserve the BIN-flag (see CAPI-draft for + //The mod_op value of the LDAPMod-struct needs to be ORed with the right + // LDAP_MOD_* constant to preserve the BIN-flag (see CAPI-draft for // explanation of the LDAPMod struct) - switch (m_mod_op){ - case OP_ADD : - ret->mod_op |= LDAP_MOD_ADD; - break; - case OP_DELETE : - ret->mod_op |= LDAP_MOD_DELETE; - break; - case OP_REPLACE : - ret->mod_op |= LDAP_MOD_REPLACE; - break; - } - return ret; + switch (m_mod_op){ + case OP_ADD : + ret->mod_op |= LDAP_MOD_ADD; + break; + case OP_DELETE : + ret->mod_op |= LDAP_MOD_DELETE; + break; + case OP_REPLACE : + ret->mod_op |= LDAP_MOD_REPLACE; + break; + } + return ret; } diff --git a/contrib/ldapc++/src/LDAPModifyRequest.cpp b/contrib/ldapc++/src/LDAPModifyRequest.cpp index c5f2fbf098..579ff8b74f 100644 --- a/contrib/ldapc++/src/LDAPModifyRequest.cpp +++ b/contrib/ldapc++/src/LDAPModifyRequest.cpp @@ -51,8 +51,9 @@ LDAPMessageQueue* LDAPModifyRequest::sendRequest(){ LDAPMod** tmpMods=m_modList->toLDAPModArray(); int err=ldap_modify_ext(m_connection->getSessionHandle(),m_dn.c_str(), tmpMods, tmpSrvCtrls, tmpClCtrls,&msgID); - ldap_controls_free(tmpSrvCtrls); - ldap_controls_free(tmpClCtrls); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls); + LDAPControlSet::freeLDAPControlArray(tmpClCtrls); + ldap_mods_free(tmpMods,1); if(err != LDAP_SUCCESS){ throw LDAPException(err); }else{ diff --git a/contrib/ldapc++/src/LDAPResult.cpp b/contrib/ldapc++/src/LDAPResult.cpp index ea54d9bf2a..598adc330a 100644 --- a/contrib/ldapc++/src/LDAPResult.cpp +++ b/contrib/ldapc++/src/LDAPResult.cpp @@ -41,11 +41,11 @@ LDAPResult::LDAPResult(const LDAPRequest *req, LDAPMessage *msg) : } if(matchedDN != 0){ m_matchedDN=string(matchedDN); - delete[] matchedDN; + free(matchedDN); } if(errMsg != 0){ m_errMsg=string(errMsg); - delete[] errMsg; + free(errMsg); } } } diff --git a/contrib/ldapc++/src/LDAPSearchRequest.cpp b/contrib/ldapc++/src/LDAPSearchRequest.cpp index e1f758083d..aa13cd77c9 100644 --- a/contrib/ldapc++/src/LDAPSearchRequest.cpp +++ b/contrib/ldapc++/src/LDAPSearchRequest.cpp @@ -71,8 +71,8 @@ LDAPMessageQueue* LDAPSearchRequest::sendRequest(){ tmpClCtrl, tmptime, m_cons->getSizeLimit(), &msgID ); delete tmptime; ldap_value_free(tmpattrs); - ldap_controls_free(tmpSrvCtrl); - ldap_controls_free(tmpClCtrl); + LDAPControlSet::freeLDAPControlArray(tmpSrvCtrl); + LDAPControlSet::freeLDAPControlArray(tmpClCtrl); if (err != LDAP_SUCCESS){ throw LDAPException(err); diff --git a/contrib/ldapc++/src/StringList.cpp b/contrib/ldapc++/src/StringList.cpp index 632a20c822..c997c42dfd 100644 --- a/contrib/ldapc++/src/StringList.cpp +++ b/contrib/ldapc++/src/StringList.cpp @@ -32,11 +32,11 @@ StringList::~StringList(){ char** StringList::toCharArray() const{ if(!empty()){ - char** ret = new char*[size()+1]; + char** ret = (char**) malloc(sizeof(char*) * (size()+1)); StringList::const_iterator i; int j=0; for(i=begin(); i != end(); i++,j++){ - ret[j]=new char[i->size()+1]; + ret[j]=(char*) malloc(sizeof(char) * (i->size()+1)); i->copy(ret[j],string::npos); ret[j][i->size()]=0; } -- 2.39.5