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 :(
std::vector<uint8> outBuffer;
outBuffer.resize(fileSize);
// decompress the file in memory
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)
if (fileSize)
{
nlwarning("Failed to decode lzma file '%s'", downloadPath.c_str());
return false;
// decompress the file in memory
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