diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index de7f3e9dc..a1a445261 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -29,6 +29,7 @@ #include "linden_common.h" #include "llapr.h" #include "llscopedvolatileaprpool.h" +#include bool ll_apr_warn_status(apr_status_t status) { @@ -150,7 +151,7 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOO return open(filename, flags, use_global_pool ? LLAPRFile::long_lived : LLAPRFile::short_lived); } // File I/O -S32 LLAPRFile::read(void *buf, S32 nbytes) +S32 LLAPRFile::read(void *buf, U64 nbytes) { if(!mFile) { @@ -167,12 +168,12 @@ S32 LLAPRFile::read(void *buf, S32 nbytes) } else { - llassert_always(sz <= 0x7fffffff); + llassert_always(sz <= std::numeric_limits::max()); return (S32)sz; } } -S32 LLAPRFile::write(const void *buf, S32 nbytes) +S32 LLAPRFile::write(const void *buf, U64 nbytes) { if(!mFile) { @@ -189,7 +190,7 @@ S32 LLAPRFile::write(const void *buf, S32 nbytes) } else { - llassert_always(sz <= 0x7fffffff); + llassert_always(sz <= std::numeric_limits::max()); return (S32)sz; } } diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 9baddef5f..0363a8faf 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -92,8 +92,8 @@ public: apr_status_t eof() { return apr_file_eof(mFile);} // Returns bytes read/written, 0 if read/write fails: - S32 read(void* buf, S32 nbytes); - S32 write(const void* buf, S32 nbytes); + S32 read(void* buf, U64 nbytes); + S32 write(const void* buf, U64 nbytes); apr_file_t* getFileHandle() {return mFile;} diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 7e4ed1ad3..ed878a02f 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1305,14 +1305,12 @@ void LLTextureCache::writeEntriesAndClose(const std::vector& entries) if (!mReadOnly) { LLAPRFile* aprfile = openHeaderEntriesFile(false, (S32)sizeof(EntriesInfo)); - for (S32 idx=0; idxwrite((void*)(entries.data()), write_size); + if (bytes_written != write_size) { - S32 bytes_written = aprfile->write((void*)(&entries[idx]), (S32)sizeof(Entry)); - if(bytes_written != sizeof(Entry)) - { - clearCorruptedCache(); //clear the cache. - return; - } + clearCorruptedCache(); //clear the cache. + return; } closeHeaderEntriesFile(); }