From d404f010c90baf6be367a98c0a86f48c38978b32 Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 12 Aug 2019 03:15:14 +0000 Subject: [PATCH] Fix some undefined behavior git-svn-id: https://svn.eduke32.com/eduke32@7950 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gameexec.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index b0aa711d2..760066f52 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -158,8 +158,12 @@ static inline void VM_DummySprite(void) static FORCE_INLINE int32_t VM_EventInlineInternal__(int const &eventNum, int const &spriteNum, int const &playerNum, int const playerDist = -1, int32_t returnValue = 0) { - vmstate_t const newVMstate = { spriteNum, playerNum, playerDist, 0, &sprite[spriteNum], - &actor[spriteNum].t_data[0], g_player[playerNum].ps, &actor[spriteNum] }; + vmstate_t const newVMstate = { spriteNum, playerNum, playerDist, 0, + &sprite[spriteNum&(MAXSPRITES-1)], + &actor[spriteNum&(MAXSPRITES-1)].t_data[0], + g_player[playerNum&(MAXPLAYERS-1)].ps, + &actor[spriteNum&(MAXSPRITES-1)] }; + auto &globalReturn = aGameVars[g_returnVarID].global; struct