Don't decompress empty file in stream package

--HG--
branch : feature-streamed-package
hg/feature/streamed-package
kaetemi 10 years ago
parent b19c685ace
commit a7af274ae0

@ -231,12 +231,15 @@ bool CStreamedPackageManager::getFile(std::string &filePath, const std::string &
// allocate the output buffer :( // allocate the output buffer :(
std::vector<uint8> outBuffer; std::vector<uint8> outBuffer;
outBuffer.resize(fileSize); outBuffer.resize(fileSize);
// decompress the file in memory if (fileSize)
ret = LzmaDecode(&state, (unsigned char *)pos, (SizeT)(inBuffer.size() - (pos - &inBuffer[0])), &inProcessed, (unsigned char*)&outBuffer[0], (SizeT)fileSize, &outProcessed);
if (ret != 0 || outProcessed != fileSize)
{ {
nlwarning("Failed to decode lzma file '%s'", downloadPath.c_str()); // decompress the file in memory
return false; ret = LzmaDecode(&state, (unsigned char *)pos, (SizeT)(inBuffer.size() - (pos - &inBuffer[0])), &inProcessed, (unsigned char*)&outBuffer[0], (SizeT)fileSize, &outProcessed);
if (ret != 0 || outProcessed != fileSize)
{
nlwarning("Failed to decode lzma file '%s'", downloadPath.c_str());
return false;
}
} }
{ {

Loading…
Cancel
Save