From ffa4e8ebb36dcb660c429e430e32c68fae9fddbf Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 26 Aug 2012 22:17:14 +0000 Subject: [PATCH] Quit the game if SE17 (warp elevator) setup fails. The spawn-time SE 17 setup uses nextsectorneighborz() which can fail (return -1) on some circumstances and would cause an OOB sector[] access. git-svn-id: https://svn.eduke32.com/eduke32@2971 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 789423c51..501df513d 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -5541,10 +5541,22 @@ int32_t A_Spawn(int32_t j, int32_t pn) T3 = sector[sect].floorz; //Stopping loc j = nextsectorneighborz(sect,sector[sect].floorz,-1,-1); - T4 = sector[j].ceilingz; + if (j >= 0) + { + T4 = sector[j].ceilingz; - j = nextsectorneighborz(sect,sector[sect].ceilingz,1,1); - T5 = sector[j].floorz; + j = nextsectorneighborz(sect,sector[sect].ceilingz,1,1); + if (j >= 0) + T5 = sector[j].floorz; + } + + if (j < 0) + { + // XXX: we should return to the menu for this and similar failures + Bsprintf(tempbuf, "SE 17 (warp elevator) setup failed: sprite %d at (%d, %d)", + i, sprite[i].x, sprite[i].y); + G_GameExit(tempbuf); + } if (numplayers < 2 && !g_netServer) {