summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturecache.cpp
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@lindenlab.com>2025-05-28 11:52:16 -0400
committerJonathan "Geenz" Goodman <geenz@lindenlab.com>2025-05-28 11:52:16 -0400
commitfe4f85e587fc01319f0570541394eeca57273ba2 (patch)
treea3abfa235b1aad022fa5d262a60d639282635bc8 /indra/newview/lltexturecache.cpp
parentaeefc73129978f6f2c1ba8caaff2750eff2cfbb3 (diff)
parentde8275b14b30bf754cdba1da867cb2e6c2783639 (diff)
Merge remote-tracking branch 'origin/main' into geenz/2025.04-to-develop
Diffstat (limited to 'indra/newview/lltexturecache.cpp')
-rw-r--r--indra/newview/lltexturecache.cpp44
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;