Fix segfault when spectating on an Emerald Hunt map
If you create a custom gametype that allows spectating on Emerald Hunt maps, spectators can trigger segfaults by simply joining the game. This happens because spectators have one single tic where player->mo
is NULL
while joining, which is enough to trigger a NULL
-dereference in the Emerald Hunt HUD logic used to detect the distance from an emerald.
This SOC can be used to trigger the bug:
GameType Spectator test
TypeOfLevel = Coop
Identifier = "spectest"
Rules = GTR_CAMPAIGN|GTR_LIVES|GTR_FRIENDLY|GTR_SPAWNENEMIES|GTR_ALLOWEXIT|GTR_EMERALDHUNT|GTR_EMERALDTOKENS|GTR_SPECIALSTAGES|GTR_CUTSCENES|GTR_SPECTATORS|GTR_NOSPECTATORSPAWN
HeaderColor = 133
RankingType = GT_COOP
IntermissionType = int_coop
Description = ""
#
To reproduce:
- Load the SOC above with a map pack that contains an Emerald Hunt map (CyberDime Realm and Sol Sestancia are two I know of).
- Start a server with the custom gametype on any Emerald Hunt map.
- Go into spectator mode.
- Join back into the game.