diff options
| author | Andrey Lihatskiy <118752495+marchcat@users.noreply.github.com> | 2025-12-04 00:30:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-04 00:30:33 +0200 |
| commit | 8c134d5a4a9f08a87104530fe910bc39434cacf2 (patch) | |
| tree | dad5ddf6daf7f5e1bc7b47cd670a99ca73d4c5a1 /indra/newview/lltexturecache.cpp | |
| parent | 2c3ce8fb8ce3967d957e13d48627b45dd32f0e00 (diff) | |
| parent | 590f58dbad3dc3db3482dba86bf2619a87a7dad5 (diff) | |
Merge pull request #5020 from secondlife/marchcat/slua-linux
develop-linux → SLua PV merge
Diffstat (limited to 'indra/newview/lltexturecache.cpp')
| -rw-r--r-- | indra/newview/lltexturecache.cpp | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 1a7ce74ccc..612af0d147 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -943,8 +943,6 @@ const char* fast_cache_filename = "FastCache.cache"; void LLTextureCache::setDirNames(ELLPath location) { - std::string delem = gDirUtilp->getDirDelimiter(); - mHeaderEntriesFileName = gDirUtilp->getExpandedFilename(location, textures_dirname, entries_filename); mHeaderDataFileName = gDirUtilp->getExpandedFilename(location, textures_dirname, cache_filename); mTexturesDirName = gDirUtilp->getExpandedFilename(location, textures_dirname); @@ -1345,21 +1343,26 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries) } aprfile->seek(APR_SET, (S32)sizeof(EntriesInfo)); } - for (U32 idx=0; idx<num_entries; idx++) + + U32 idx = 0; + try { - try + entries.resize(num_entries); + S32 total_entries_size = sizeof(Entry) * num_entries; + S32 bytes_read = aprfile->read((void*)entries.data(), total_entries_size); + if (bytes_read != total_entries_size) { - Entry entry; - S32 bytes_read = aprfile->read((void*)(&entry), (S32)sizeof(Entry)); - if (bytes_read < sizeof(Entry)) - { - LL_WARNS() << "Corrupted header entries, failed at " << idx << " / " << num_entries << LL_ENDL; - closeHeaderEntriesFile(); - return 0; - } - entries.push_back(entry); - // LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL; - if (entry.mImageSize > entry.mBodySize) + LL_WARNS() << "Corrupted header entries, expected " << total_entries_size << " bytes but got " << bytes_read << " bytes" << LL_ENDL; + closeHeaderEntriesFile(); + purgeAllTextures(false); + return 0; + } + + for (; idx < num_entries; idx++) + { + const Entry& entry = entries[idx]; +// LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL; + if(entry.mImageSize > entry.mBodySize) { mHeaderIDMap[entry.mID] = idx; mTexturesSizeMap[entry.mID] = entry.mBodySize; @@ -1370,17 +1373,17 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries) mFreeList.insert(idx); } } - catch (std::bad_alloc&) - { - // Too little ram yet very large cache? - // Should this actually crash viewer? - entries.clear(); - LL_WARNS() << "Bad alloc trying to read texture entries from cache, mFreeList: " << (S32)mFreeList.size() - << ", added entries: " << idx << ", total entries: " << num_entries << LL_ENDL; - closeHeaderEntriesFile(); - purgeAllTextures(false); - return 0; - } + } + catch (const std::bad_alloc&) + { + // Too little ram yet very large cache? + // Should this actually crash viewer? + entries.clear(); + LL_WARNS() << "Bad alloc trying to read texture entries from cache, mFreeList: " << (S32)mFreeList.size() + << ", added entries: " << idx << ", total entries: " << num_entries << LL_ENDL; + closeHeaderEntriesFile(); + purgeAllTextures(false); + return 0; } closeHeaderEntriesFile(); return num_entries; |
