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,6 +231,8 @@ 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);
if (fileSize)
{
// decompress the file in memory // 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); 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 (ret != 0 || outProcessed != fileSize)
@ -238,6 +240,7 @@ bool CStreamedPackageManager::getFile(std::string &filePath, const std::string &
nlwarning("Failed to decode lzma file '%s'", downloadPath.c_str()); nlwarning("Failed to decode lzma file '%s'", downloadPath.c_str());
return false; return false;
} }
}
{ {
COFile outStream(unpackPath); COFile outStream(unpackPath);

Loading…
Cancel
Save