From 151287168c844be2b3330681897dba84b8b23031 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 9 Dec 2011 19:11:31 +0000 Subject: [PATCH] - Fix invalid polymer light array access originating from game's cleanup callback 'G_Polymer_UnInit'. - In astub.c, reset spritelightid to -1 when nulling the spritelightptr of a sprite (no crashes observed, just precaution) - In sdlayer.c, catch SIGILLs with our signal handler too, since illegal instructions are what the instrumented debug builds will execute when attempting to carry out an undefined (per C) operation. git-svn-id: https://svn.eduke32.com/eduke32@2169 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/sdlayer.c | 1 + polymer/eduke32/source/actors.c | 3 ++- polymer/eduke32/source/astub.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 1ef1a21e4..b126d9b17 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -319,6 +319,7 @@ int32_t initsystem(void) } signal(SIGSEGV, sighandler); + signal(SIGILL, sighandler); /* clang -fcatch-undefined-behavior uses an ill. insn */ signal(SIGABRT, sighandler); signal(SIGFPE, sighandler); diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index e063160b0..23f9a548b 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -487,7 +487,8 @@ int32_t block_deletesprite = 0; #ifdef POLYMER static void A_DeletePolymerLight(int32_t s) { - polymer_deletelight(actor[s].lightId); + if (actor[s].lightId >= 0) + polymer_deletelight(actor[s].lightId); actor[s].lightId = -1; actor[s].lightptr = NULL; } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 1a1093c9e..e69ba2402 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -315,6 +315,7 @@ static void DeletePolymerLights(void) if (spritelightptr[i] != NULL) { polymer_deletelight(spritelightid[i]); + spritelightid[i] = -1; spritelightptr[i] = NULL; } }