Skip to content
Snippets Groups Projects
Commit 2f062b9e authored by Tofu Linden's avatar Tofu Linden
Browse files

CID-105

Checker: INVALIDATE_ITERATOR
Function: LLLocationHistory::addItem(const LLLocationHistoryItem &)
File: /indra/newview/lllocationhistory.cpp
parent a0bc58aa
No related branches found
No related tags found
No related merge requests found
...@@ -50,18 +50,19 @@ void LLLocationHistory::addItem(const LLLocationHistoryItem& item) { ...@@ -50,18 +50,19 @@ void LLLocationHistory::addItem(const LLLocationHistoryItem& item) {
// check if this item doesn't duplicate any existing one // check if this item doesn't duplicate any existing one
location_list_t::iterator item_iter = std::find(mItems.begin(), mItems.end(),item); location_list_t::iterator item_iter = std::find(mItems.begin(), mItems.end(),item);
if(item_iter != mItems.end()){ if(item_iter != mItems.end()) // if it already exists, erase the old one
{
mItems.erase(item_iter); mItems.erase(item_iter);
} }
mItems.push_back(item); mItems.push_back(item);
// If the vector size exceeds the maximum, purge the oldest items. // If the vector size exceeds the maximum, purge the oldest items (at the start of the mItems vector).
if ((S32)mItems.size() > max_items) { if ((S32)mItems.size() > max_items)
for(location_list_t::iterator i = mItems.begin(); i != mItems.end()-max_items; ++i) { {
mItems.erase(i); mItems.erase(mItems.begin(), mItems.end()-max_items);
}
} }
llassert(mItems.size() <= max_items);
} }
/* /*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment