Skip to content

Commit 34dcaaa

Browse files
committed
#4887 Fix access violation in LLInventoryModelBackgroundFetch::bulkFetchViaAis
1 parent d0b7731 commit 34dcaaa

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

indra/newview/llinventorymodelbackgroundfetch.cpp

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -886,31 +886,34 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
886886
static LLCachedControl<S32> ais_batch(gSavedSettings, "BatchSizeAIS3", 20);
887887
S32 batch_limit = llclamp(ais_batch(), 1, 40);
888888

889-
for (LLInventoryModel::cat_array_t::iterator it = categories->begin();
890-
it != categories->end();
891-
++it)
889+
if (categories)
892890
{
893-
LLViewerInventoryCategory* child_cat = (*it);
894-
if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion()
895-
|| child_cat->getFetching() >= target_state)
891+
for (LLInventoryModel::cat_array_t::iterator it = categories->begin();
892+
it != categories->end();
893+
++it)
896894
{
897-
continue;
898-
}
895+
LLViewerInventoryCategory* child_cat = (*it);
896+
if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion()
897+
|| child_cat->getFetching() >= target_state)
898+
{
899+
continue;
900+
}
899901

900-
if (child_cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_LISTINGS)
901-
{
902-
// special case, marketplace will fetch that as needed
903-
continue;
904-
}
902+
if (child_cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_LISTINGS)
903+
{
904+
// special case, marketplace will fetch that as needed
905+
continue;
906+
}
905907

906-
children.emplace_back(child_cat->getUUID());
907-
mExpectedFolderIds.emplace_back(child_cat->getUUID());
908-
child_cat->setFetching(target_state);
908+
children.emplace_back(child_cat->getUUID());
909+
mExpectedFolderIds.emplace_back(child_cat->getUUID());
910+
child_cat->setFetching(target_state);
909911

910-
if (children.size() >= batch_limit)
911-
{
912-
content_done = false;
913-
break;
912+
if (children.size() >= batch_limit)
913+
{
914+
content_done = false;
915+
break;
916+
}
914917
}
915918
}
916919

@@ -940,14 +943,17 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
940943
// This will have a bit of overlap with onAISContentCalback,
941944
// but something else might have downloaded folders, so verify
942945
// every child that is complete has it's children done as well
943-
for (LLInventoryModel::cat_array_t::iterator it = categories->begin();
944-
it != categories->end();
945-
++it)
946+
if (categories)
946947
{
947-
LLViewerInventoryCategory* child_cat = (*it);
948-
if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion())
948+
for (LLInventoryModel::cat_array_t::iterator it = categories->begin();
949+
it != categories->end();
950+
++it)
949951
{
950-
mFetchFolderQueue.emplace_back(child_cat->getUUID(), FT_RECURSIVE);
952+
LLViewerInventoryCategory* child_cat = (*it);
953+
if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion())
954+
{
955+
mFetchFolderQueue.emplace_back(child_cat->getUUID(), FT_RECURSIVE);
956+
}
951957
}
952958
}
953959
}
@@ -998,12 +1004,15 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
9981004
LLInventoryModel::cat_array_t* categories(NULL);
9991005
LLInventoryModel::item_array_t* items(NULL);
10001006
gInventory.getDirectDescendentsOf(cat_id, categories, items);
1001-
for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
1002-
it != categories->end();
1003-
++it)
1007+
if (categories)
10041008
{
1005-
// not emplace_front to not cause an infinite loop
1006-
mFetchFolderQueue.emplace_back((*it)->getUUID(), FT_RECURSIVE);
1009+
for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
1010+
it != categories->end();
1011+
++it)
1012+
{
1013+
// not emplace_front to not cause an infinite loop
1014+
mFetchFolderQueue.emplace_back((*it)->getUUID(), FT_RECURSIVE);
1015+
}
10071016
}
10081017
}
10091018
}

0 commit comments

Comments
 (0)