From 4457a5fbca5d7b22ba9539ec06e34a81d4271cff Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 30 May 2013 09:13:34 +0000 Subject: [PATCH] Fix potential oob access when flipping the floor [F] in 2D mode. git-svn-id: https://svn.eduke32.com/eduke32@3824 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/astub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index ec91fd54f..20277f12a 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4775,12 +4775,14 @@ static void toggle_cf_flipping(int32_t sectnum, int32_t floorp) static const int16_t orient[8] = { 360, -360, -180, 180, -270, 270, 90, -90 }; - uint16_t *stat = &SECTORFLD(sectnum,stat, floorp); + const int32_t search = floorp ? SEARCH_FLOOR : SEARCH_CEILING; + + uint16_t *const stat = &SECTORFLD(sectnum,stat, floorp); int32_t i = *stat; i = (i&0x4)+((i>>4)&3); i = eitherSHIFT ? prev3[i] : next3[i]; - message("Sector %d %s flip %d deg%s", searchsector, typestr[searchstat], + message("Sector %d %s flip %d deg%s", sectnum, typestr[search], klabs(orient[i])%360, orient[i] < 0 ? " mirrored":""); i = (i&0x4)+((i&3)<<4); *stat &= ~0x34;