Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11707


Ignore:
Timestamp:
Jan 6, 2018, 4:34:18 PM (6 years ago)
Author:
landauf
Message:

fixed nullptr access when two pawns trigger a pickup-spawner at the same time (for the second pawn in the list, the pickup is already nullptr → crash)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r11103 r11707  
    158158            for(Pawn* pawn : ObjectList<Pawn>())
    159159            {
    160                 if(spawner == nullptr) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute).
    161                     break;
    162 
    163160                Vector3 distance = pawn->getWorldPosition() - this->getWorldPosition();
    164161                PickupCarrier* carrier = static_cast<PickupCarrier*>(pawn);
     
    167164                {
    168165                    if(carrier->isTarget(this->pickup_))
    169                         this->trigger(pawn);
     166                    {
     167                        this->trigger(pawn); // Attention: after this line, pickup_ is probably nullptr (because it was taken) and even spawner can be nullptr (if it run out of pickups)!
     168                        break;
     169                    }
    170170                }
    171171            }
Note: See TracChangeset for help on using the changeset viewer.