summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2026-03-16 17:45:55 +0200
committerAndrey Lihatskiy <118752495+marchcat@users.noreply.github.com>2026-03-16 23:12:26 +0200
commit75a98ba9aa932d76227d50e739ae4beb722a3cc6 (patch)
treee17e209c42098a6fc0b13af406b6d0a3e07263ed /indra
parent4034714980dd36a454639b1324cfac6a6bd8bf59 (diff)
#5541 Add safety checks for inventory save during shutdown
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llinventorymodel.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index c2f9c483c0..187b2248de 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -2383,10 +2383,22 @@ void LLInventoryModel::cache(
items,
INCLUDE_TRASH,
can_cache);
+
+ if (categories.empty() && items.empty())
+ {
+ LL_WARNS(LOG_INV) << "Nothing to cache for " << parent_folder_id << LL_ENDL;
+ return;
+ }
+
// Use temporary file to avoid potential conflicts with other
// instances (even a 'read only' instance unzips into a file)
std::string temp_file = gDirUtilp->getTempFilename();
- saveToFile(temp_file, categories, items);
+ if (!saveToFile(temp_file, categories, items))
+ {
+ LL_WARNS(LOG_INV) << "Failed to save inventory cache for " << parent_folder_id << LL_ENDL;
+ LLFile::remove(temp_file);
+ return;
+ }
std::string gzip_filename = getInvCacheAddres(agent_id);
gzip_filename.append(".gz");
if(gzip_file(temp_file, gzip_filename))
@@ -3537,6 +3549,11 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
S32 cat_count = 0;
for (auto& cat : categories)
{
+ if (cat.isNull())
+ {
+ LL_WARNS(LOG_INV) << "Skipping null category during inventory save" << LL_ENDL;
+ continue;
+ }
if (cat->getVersion() != LLViewerInventoryCategory::VERSION_UNKNOWN)
{
LLSD sd;
@@ -3551,6 +3568,11 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
auto it_count = items.size();
for (auto& item : items)
{
+ if (item.isNull())
+ {
+ LL_WARNS(LOG_INV) << "Skipping null item during inventory save" << LL_ENDL;
+ continue;
+ }
LLSD sd;
item->asLLSD(sd);
item_array.append(sd);