Okay i´ve fixxed it even if i dont know if its good like this but it works for me
Replaced:
bool CProperty::ReadFromMemory(const void * c_pvData, int iLen, const char * c_pszFileName)
{
const char * pcData = (const char *) c_pvData;
if (*(DWORD *) pcData != MAKEFOURCC('Y', 'P', 'R', 'T'))
return false;
pcData += sizeof(DWORD);
if (*pcData != '\r' || *(pcData + 1) != '\n')
{
TraceError("CProperty::ReadFromMemory: File format error after FourCC: %s\n", c_pszFileName);
return false;
}
pcData += 2;
CTokenVector stTokenVector;
/*
char szTimeStamp[64];
memcpy(szTimeStamp, pcData, 14);
szTimeStamp[14] = '\0';
pcData += 14;
if (*pcData != '\r' || *(pcData + 1) != '\n')
{
TraceError("CProperty::ReadFromMemory: File format error after TimeStamp: %s\n", c_pszFileName);
return false;
}
std::string m_stTimeStamp;
m_stTimeStamp = szTimeStamp;
int iTimeStampLen = 14 + _snprintf(szTimeStamp + 14, 64 - 14, "%s", mc_pFileName);
m_dwCRC = GetCRC32(szTimeStamp, iTimeStampLen);
char tmp[64];
sprintf(tmp, "%u", m_dwCRC);
m_stCRC.assign(tmp);
CMemoryTextFileLoader textFileLoader;
textFileLoader.Bind(iLen - (sizeof(DWORD) + 2 + 14 + 2), pcData);
for (DWORD i = 0; i < textFileLoader.GetLineCount(); ++i)
{
if (!textFileLoader.SplitLine(i, &stTokenVector))
continue;
stl_lowers(stTokenVector[0]);
std::string stKey = stTokenVector[0];
stTokenVector.erase(stTokenVector.begin());
PutVector(stKey.c_str(), stTokenVector);
}
return true;
*/
CMemoryTextFileLoader textFileLoader;
textFileLoader.Bind(iLen - (sizeof(DWORD) + 2), pcData);
m_stCRC = textFileLoader.GetLineString(0);
m_dwCRC = atoi(m_stCRC.c_str());
for (DWORD i = 1; i < textFileLoader.GetLineCount(); ++i)
{
if (!textFileLoader.SplitLine(i, &stTokenVector))
continue;
stl_lowers(stTokenVector[0]);
std::string stKey = stTokenVector[0];
stTokenVector.erase(stTokenVector.begin());
PutVector(stKey.c_str(), stTokenVector);
}
//Tracef("Property: %s\n", c_pszFileName);
return true;
}
With:
bool CProperty::ReadFromMemory(const void * c_pvData, int iLen, const char * c_pszFileName)
{
const char* pStart = (const char*)c_pvData;
const char* pcData = pStart;
if (*(DWORD *) pcData != MAKEFOURCC('Y', 'P', 'R', 'T'))
return false;
pcData += sizeof(DWORD);
while (pcData < pStart + iLen && (*pcData == '\r' || *pcData == '\n' || *pcData == ' ' || *pcData == '\t'))
++pcData;
int textLen = iLen - int(pcData - pStart);
if (textLen <= 0)
{
TraceError("CProperty::ReadFromMemory: textLen <= 0 in %s\n", c_pszFileName);
return false;
}
CTokenVector stTokenVector;
CMemoryTextFileLoader textFileLoader;
textFileLoader.Bind(textLen, pcData);
m_stCRC.clear();
m_dwCRC = 0;
if (textFileLoader.GetLineCount() > 0)
{
m_stCRC = textFileLoader.GetLineString(0);
bool bAllDigits = !m_stCRC.empty() && std::all_of(m_stCRC.begin(), m_stCRC.end(), [](char c)
{
return isdigit((unsigned char)c);
});
DWORD startLine = 0;
if (bAllDigits)
{
m_dwCRC = atoi(m_stCRC.c_str());
startLine = 1;
}
for (DWORD i = startLine; i < textFileLoader.GetLineCount(); ++i)
{
if (!textFileLoader.SplitLine(i, &stTokenVector))
continue;
stl_lowers(stTokenVector[0]);
std::string stKey = stTokenVector[0];
stTokenVector.erase(stTokenVector.begin());
PutVector(stKey.c_str(), stTokenVector);
}
}
return true;
}