1
0

Compression error -5 fix

git-svn-id: http://mc-server.googlecode.com/svn/trunk@452 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-04-04 14:36:52 +00:00
parent 3fe1622eda
commit e009569060

View File

@ -40,12 +40,13 @@ int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed
// It saves us one allocation and one memcpy of the entire compressed data
// It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
a_Uncompressed.resize(a_UncompressedSize);
int errorcode = uncompress((Bytef*)a_Uncompressed.data(), (uLongf *)&a_UncompressedSize, (const Bytef*)a_Data, a_Length);
uLongf UncompressedSize = (uLongf)a_UncompressedSize; // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error
int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, a_Length);
if (errorcode != Z_OK)
{
return errorcode;
}
a_Uncompressed.resize(a_UncompressedSize);
a_Uncompressed.resize(UncompressedSize);
return Z_OK;
}