From a7af274ae0629bd2bfb937f5aa538e7285ad06f3 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 12 Dec 2014 01:21:07 +0100 Subject: [PATCH] Don't decompress empty file in stream package --HG-- branch : feature-streamed-package --- code/nel/src/misc/streamed_package_manager.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/code/nel/src/misc/streamed_package_manager.cpp b/code/nel/src/misc/streamed_package_manager.cpp index fbdfc1f5a..8114da948 100644 --- a/code/nel/src/misc/streamed_package_manager.cpp +++ b/code/nel/src/misc/streamed_package_manager.cpp @@ -231,12 +231,15 @@ bool CStreamedPackageManager::getFile(std::string &filePath, const std::string & // allocate the output buffer :( std::vector 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; + } } {