@@ -434,17 +434,26 @@ void OpenContain::removeAllContained( Bool exposeStealthUnits )
434
434
// -------------------------------------------------------------------------------------------------
435
435
void OpenContain::killAllContained ( void )
436
436
{
437
- ContainedItemsList::iterator it = m_containList.begin ();
437
+ // TheSuperHackers @bugfix xezon 23/05/2025 Empty m_containList straight away
438
+ // to prevent a potential child call to catastrophically modify the m_containList as well.
439
+ // This scenario can happen if the killed occupant(s) apply deadly damage on death
440
+ // to the host container, which then attempts to remove all remaining occupants
441
+ // on the death of the host container. This is reproducible by shooting with
442
+ // Neutron Shells on a GLA Technical containing GLA Terrorists.
443
+ ContainedItemsList list;
444
+ list.swap (m_containList);
445
+ m_containListSize = 0 ;
438
446
439
- while ( it != m_containList.end () )
447
+ ContainedItemsList::iterator it = list.begin ();
448
+
449
+ while ( it != list.end () )
440
450
{
441
451
Object *rider = *it;
442
452
443
-
453
+ DEBUG_ASSERTCRASH ( rider, ( " Contain list must not contain NULL element " ));
444
454
if ( rider )
445
455
{
446
- it = m_containList.erase (it);
447
- m_containListSize--;
456
+ it = list.erase (it);
448
457
449
458
onRemoving ( rider );
450
459
rider->onRemovedFrom ( getObject () );
@@ -459,7 +468,7 @@ void OpenContain::killAllContained( void )
459
468
460
469
DEBUG_ASSERTCRASH ( m_containListSize == 0 , (" killallcontain just made a booboo, list size != zero." ) );
461
470
462
- } // end removeAllContained
471
+ } // end killAllContained
463
472
464
473
// --------------------------------------------------------------------------------------------------------
465
474
/* * Force all contained objects in the contained list to exit, and kick them in the pants on the way out*/
@@ -472,6 +481,7 @@ void OpenContain::harmAndForceExitAllContained( DamageInfo *info )
472
481
{
473
482
Object *rider = *it;
474
483
484
+ DEBUG_ASSERTCRASH ( rider, (" Contain list must not contain NULL element" ));
475
485
if ( rider )
476
486
{
477
487
removeFromContain ( rider, true );
@@ -490,7 +500,7 @@ void OpenContain::harmAndForceExitAllContained( DamageInfo *info )
490
500
491
501
DEBUG_ASSERTCRASH ( m_containListSize == 0 , (" harmAndForceExitAllContained just made a booboo, list size != zero." ) );
492
502
493
- } // end removeAllContained
503
+ } // end harmAndForceExitAllContained
494
504
495
505
496
506
// -------------------------------------------------------------------------------------------------
0 commit comments