Skip to content

Commit

Permalink
#3473 Fix crash at mActiveObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
akleshchev committed Jan 27, 2025
1 parent d5c6eb9 commit f353fb4
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions indra/newview/llviewerobjectlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,20 +1466,25 @@ void LLViewerObjectList::removeFromActiveList(LLViewerObject* objectp)
{
S32 idx = objectp->getListIndex();
if (idx != -1)
{ //remove by moving last element to this object's position
llassert(mActiveObjects[idx] == objectp);

{
objectp->setListIndex(-1);

S32 last_index = static_cast<S32>(mActiveObjects.size()) - 1;

if (idx != last_index)
S32 size = (S32)mActiveObjects.size();
if (size > 0) // mActiveObjects could have been cleaned already
{
mActiveObjects[idx] = mActiveObjects[last_index];
mActiveObjects[idx]->setListIndex(idx);
}
// Remove by moving last element to this object's position

mActiveObjects.pop_back();
llassert(idx < size); // idx should be always within mActiveObjects, unless killAllObjects was called
llassert(mActiveObjects[idx] == objectp); // object should be there

S32 last_index = size - 1;
if (idx < last_index)
{
mActiveObjects[idx] = mActiveObjects[last_index];
mActiveObjects[idx]->setListIndex(idx);
}
mActiveObjects.pop_back();
}
}
}

Expand Down

0 comments on commit f353fb4

Please sign in to comment.