gameexec.c: In VM_OnEvent_, don't form address like &sprite[-1].

The practical rationale: Clang-sanitize catches this, so this is bad.
The real rationale: I *think* it is undefined behavior to even form such a
pointer in C99. However, I would be hard pressed to provide a nice formal
argument in terms of the Standard wording right now. It looks like
6.5.3.2#4 is to blame.

git-svn-id: https://svn.eduke32.com/eduke32@4727 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-11-06 23:43:51 +00:00
parent 737af0387e
commit e278842ce4

View file

@ -137,7 +137,13 @@ int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t l
if (ret == 1)
VM_KillIt(iActor, iPlayer);
#else
vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0], &sprite[iActor], 0 }, vm_backup = vm;
const vmstate_t vm_backup = vm;
vmstate_t tempvm = {
iActor, iPlayer, lDist,
NULL, NULL, // to be set in a moment
0
};
int32_t backupReturnVar = aGameVars[g_iReturnVarID].val.lValue;
int32_t backupEventExec = g_currentEventExec;
intptr_t *oinsptr=insptr;
@ -150,6 +156,11 @@ int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t l
tempvm.g_sp = &dummy_sprite;
tempvm.g_t = dummy_t;
}
else
{
tempvm.g_sp = &sprite[iActor];
tempvm.g_t = &actor[iActor].t_data[0];
}
vm = tempvm;