summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2025-01-27 20:08:24 +0200
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-01-27 22:18:35 +0200
commit52a9316207f225e39a1e192ee8e666631ba6a646 (patch)
treec63aef1c0da633522429235d60bb2c018fc19fa0
parentd5c6eb92da968886e1afca299d55196557a06a10 (diff)
#3473 Fix crash at mActiveObjects
-rw-r--r--indra/newview/llviewerobjectlist.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index cd9d152437..d72d428c08 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -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);
+ } // else assume it's the last element, no need to swap
+ mActiveObjects.pop_back();
+ }
}
}