summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorVadim ProductEngine <vsavchuk@productengine.com>2012-01-10 16:35:36 +0200
committerVadim ProductEngine <vsavchuk@productengine.com>2012-01-10 16:35:36 +0200
commita47e9bd97b9855ca8bb3309a73d33d9ae593fd7d (patch)
treef6a860caad31f800b74a0ca666d36224c8801960 /indra/llcommon
parentc4a08e6c9d9f044532fcfd4eeeb8934f2c1f3dda (diff)
EXP-1525 FIXED Potential fix for a crash at shutdown: added some error handling to saving inventory cache.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llsys.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 19075afa68..6073bcd0a6 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -1364,11 +1364,21 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile)
src = LLFile::fopen(srcfile, "rb"); /* Flawfinder: ignore */
if (! src) goto err;
- do
+ while ((bytes = (S32)fread(buffer, sizeof(U8), COMPRESS_BUFFER_SIZE, src)) > 0)
{
- bytes = (S32)fread(buffer, sizeof(U8), COMPRESS_BUFFER_SIZE,src);
- gzwrite(dst, buffer, bytes);
- } while(feof(src) == 0);
+ if (gzwrite(dst, buffer, bytes) <= 0)
+ {
+ llwarns << "gzwrite failed: " << gzerror(dst, NULL) << llendl;
+ goto err;
+ }
+ }
+
+ if (ferror(src))
+ {
+ llwarns << "Error reading " << srcfile << llendl;
+ goto err;
+ }
+
gzclose(dst);
dst = NULL;
#if LL_WINDOWS