Hello friends,
i am facing issues while finding the reason for a segmentation fault in a CPP-application. Please let me know how to move forward to look for this error,
i have a doubt on the following code snippet as this CPP code uses malloc function instead of new.
can it be the reason for the segmentiaon fault?
LDAPMessageQueue* LDAPExtRequest::sendRequest(){
DEBUG(LDAP_DEBUG_TRACE, "LDAPExtRequest::sendRequest()" << endl);
int msgID=0;
BerValue* tmpdata=0;
if(m_data != ""){
[B] tmpdata=(BerValue*) malloc(sizeof(BerValue));[/B]
tmpdata->bv_len = m_data.size();
[B] tmpdata->bv_val = (char*) malloc(sizeof(char) * (m_data.size()) );[/B]
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);
LDAPControlSet::freeLDAPControlArray(tmpSrvCtrls);
LDAPControlSet::freeLDAPControlArray(tmpClCtrls);
ber_bvfree(tmpdata);
if(err != LDAP_SUCCESS){
delete this;
throw LDAPException(err);
}else{
m_msgID=msgID;
return new LDAPMessageQueue(this);
}
}
please help!