• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Fix/Patch Mysql++Connector - RAM lack

Gandh1

Member
Joined
Jan 15, 2008
Messages
16
Reaction score
8
Hi. Sorry for not best english.

Today I got problem with logging into new created project based on TFS 0.4, compiled with mysql++. When I was entering into game as Account Manager, I had memory lack - RAM increased to almost full limit, and I got message on console like "Allocation error".

After checking a code, I found, that the lack is when loading player's conditions field - reading stream / blob from database. Open file databasemysqlpp.cpp, find function
Code:
const char* MySQLppResult::getDataStream(const std::string& s, uint64_t& size)

And error is in this line:
Code:
  for(char c = result->get(); c; c = result->get())

This loop is endless, because istream::get() isn't returning 0 on end of stream, but returns EOF macro, that on C++ is -1 (possitive value).

Change this line with this one:
Code:
  for(char c = result->get(); c != EOF; c = result->get())

And 'vala - this has worked for me. I'm giving it here, on otland, because it can be helpful for other, and after checking in TFS 0.3.7 I found, that there is no fix for it (I didn't checked newer revs).

Important informations found on: http://www.cplusplus.com/reference/istream/istream/get/
 
I use 0.4 i dont remember the rev, this will ram lack?

Code:
const char* MySQLResult::getDataStream(const std::string& s, uint64_t& size)
{
    size = 0;
    listNames_t::iterator it = m_listNames.find(s);
    if(it == m_listNames.end())
    {
        std::clog << "Error during getDataStream(" << s << ")." << std::endl;
        return NULL; // Failed
    }

    if(!m_row[it->second])
        return NULL;

    size = mysql_fetch_lengths(m_handle)[it->second];
    return m_row[it->second];
}
 
Back
Top