diff --git a/src/game/chraction.c b/src/game/chraction.c index 04ceeb77e..1f1dd0f18 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -8275,7 +8275,12 @@ void chrAlertOthersOfInjury(struct chrdata *chr, bool dying) index = chr->act_dead.notifychrindex; } +#ifdef AVOID_UB + // notifychrindex can be < 0, so avoid reading g_ChrSlots when that is the case + for (; index >= 0 && index < numchrs && numinrange < 7; index++) { +#else for (; index < numchrs && numinrange < 7; index++) { +#endif struct chrdata *loopchr = &g_ChrSlots[index]; if (loopchr->model && loopchr->prop && (loopchr->prop->flags & PROPFLAG_ENABLED)) { @@ -8488,12 +8493,6 @@ void chrTickDruggedComingUp(struct chrdata *chr) chrUncloak(chr, true); chr->actiontype = ACT_DRUGGEDDROP; -#ifdef AVOID_UB - // the function that checks notifychrindex checks for ACT_DRUGGEDDROP, - // so in theory it could check it before the drop animation is finished, - // which will cause a crash. or at least I think that's what's happening - chr->act_die.notifychrindex = 0; -#endif while (!done) { if (i >= 0