@@ -2383,10 +2383,22 @@ void LLInventoryModel::cache(
23832383 items,
23842384 INCLUDE_TRASH,
23852385 can_cache);
2386+
2387+ if (categories.empty () && items.empty ())
2388+ {
2389+ LL_WARNS (LOG_INV) << " Nothing to cache for " << parent_folder_id << LL_ENDL;
2390+ return ;
2391+ }
2392+
23862393 // Use temporary file to avoid potential conflicts with other
23872394 // instances (even a 'read only' instance unzips into a file)
23882395 std::string temp_file = gDirUtilp ->getTempFilename ();
2389- saveToFile (temp_file, categories, items);
2396+ if (!saveToFile (temp_file, categories, items))
2397+ {
2398+ LL_WARNS (LOG_INV) << " Failed to save inventory cache for " << parent_folder_id << LL_ENDL;
2399+ LLFile::remove (temp_file);
2400+ return ;
2401+ }
23902402 std::string gzip_filename = getInvCacheAddres (agent_id);
23912403 gzip_filename.append (" .gz" );
23922404 if (gzip_file (temp_file, gzip_filename))
@@ -3537,6 +3549,11 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
35373549 S32 cat_count = 0 ;
35383550 for (auto & cat : categories)
35393551 {
3552+ if (cat.isNull ())
3553+ {
3554+ LL_WARNS (LOG_INV) << " Skipping null category during inventory save" << LL_ENDL;
3555+ continue ;
3556+ }
35403557 if (cat->getVersion () != LLViewerInventoryCategory::VERSION_UNKNOWN)
35413558 {
35423559 LLSD sd;
@@ -3551,6 +3568,11 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
35513568 auto it_count = items.size ();
35523569 for (auto & item : items)
35533570 {
3571+ if (item.isNull ())
3572+ {
3573+ LL_WARNS (LOG_INV) << " Skipping null item during inventory save" << LL_ENDL;
3574+ continue ;
3575+ }
35543576 LLSD sd;
35553577 item->asLLSD (sd);
35563578 item_array.append (sd);
0 commit comments