First memory error: HEAP[xchar.exe]: HEAP: Free Heap block 8a6800 modified at 8a6890 after it was freedCode:/* INFO : char* msg; */ SocketClient c(hostname, port); string ret = c.ReceiveLine(); //Receives a string where its length is 22 c.SendLine("EHLO"); c.SendLine("AUTH PLAIN"); char s = '\0'; ret = username; ret += s; ret += username; ret += s; ret += password; msg = new char(ret.length()+1); Crypt::Base64Encode((unsigned char *)msg, (const unsigned char*)ret.c_str(), ret.length()); try { c.SendLine(msg); //First memory error } catch (std::bad_alloc ex) { cout<<"error\n"<<ex.what(); //yes, we got some bad allocation error } ret = c.ReceiveLine(); //Second memory error .... std::string Socket::ReceiveLine() { std::string ret; while (1) { char r; switch(recv(s_, &r, 1, 0)) { case 0: // not connected anymore; return ""; case -1: /*if (errno == EAGAIN) { return ret; } else { // not connected anymore*/ return ""; //} } ret += r; if (r == '\n') return ret; } } ... void Socket::SendLine(std::string s) { s += '\n'; send(s_,s.c_str(),s.length(),0); }
Second memory error: Unhandled exception at 0x7c812a5b in xchar.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012eee0
OS = Windows XP Professional SP2
Compiler = Visual Studio 2005



LinkBack URL
About LinkBacks


