From ae63745eb394383a87916173755f017701b2f289 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 30 Oct 2014 21:44:21 +0000 Subject: [PATCH] C-CON: fix possible crash when a CON error is raised due to access of invalid sprite. For example, in CON_ERRPRINTF("invalid target sprite (%d) %d %d\n", iActor, vm.g_i, TrackerCast(vm.g_sp->picnum)); vm.g_i can be -1 and vm.g_sp can be NULL then. (Not anymore.) DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4709 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gameexec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 0d3485596..102a24ef6 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -140,9 +140,12 @@ int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t l intptr_t *oinsptr=insptr; vmstate_t vm_backup; - vmstate_t tempvm ={ iActor, iPlayer, lDist, - iActor >= 0 ? &actor[iActor].t_data[0] : NULL, - iActor >= 0 ? &sprite[iActor] : NULL, + static spritetype dummy_sprite; + static int32_t dummy_t[ARRAY_SIZE(actor[0].t_data)]; + + vmstate_t tempvm = { iActor, iPlayer, lDist, + iActor >= 0 ? &actor[iActor].t_data[0] : dummy_t, + iActor >= 0 ? &sprite[iActor] : &dummy_sprite, 0 }; int32_t backupReturnVar = aGameVars[g_iReturnVarID].val.lValue;