diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-05-28 21:38:00 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-05-28 21:38:00 +0300 |
commit | b08ba3fa7bc9e6309891e510fbfb5c4e2b5c922e (patch) | |
tree | 3e5294e3b8ff07778e6134ed9dd41458386032ac /indra/newview/lltexturecache.cpp | |
parent | b9ab6c3644da02bed6941dc8df433fb1c626f8c7 (diff) | |
parent | de8275b14b30bf754cdba1da867cb2e6c2783639 (diff) |
Merge branch 'main' into marchcat/2505-merge
# Conflicts:
# .github/workflows/qatest.yaml
# indra/llcommon/llsdutil.h
# indra/llui/llflatlistview.h
# indra/newview/llinventorybridge.cpp
# indra/newview/lloutfitgallery.cpp
# indra/newview/lloutfitgallery.h
Diffstat (limited to 'indra/newview/lltexturecache.cpp')
-rw-r--r-- | indra/newview/lltexturecache.cpp | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index be7653c011..442c627d07 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1347,27 +1347,39 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries) } for (U32 idx=0; idx<num_entries; idx++) { - Entry entry; - S32 bytes_read = aprfile->read((void*)(&entry), (S32)sizeof(Entry)); - if (bytes_read < sizeof(Entry)) + try + { + 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; + 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) + { + mHeaderIDMap[entry.mID] = idx; + mTexturesSizeMap[entry.mID] = entry.mBodySize; + mTexturesSizeTotal += entry.mBodySize; + } + else + { + mFreeList.insert(idx); + } + } + catch (std::bad_alloc&) { - LL_WARNS() << "Corrupted header entries, failed at " << idx << " / " << num_entries << LL_ENDL; + // 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; } - entries.push_back(entry); -// 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; - mTexturesSizeTotal += entry.mBodySize; - } - else - { - mFreeList.insert(idx); - } } closeHeaderEntriesFile(); return num_entries; |