From b79ee4255388eb245bc2f17cd567f632851cbd35 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 15 Jan 2014 20:29:09 +0000 Subject: [PATCH] Per-map ART tiles: don't back up or restore reserved tiles. This prevents a crash and maybe other badnesses when e.g. loading a map with ART tiles, doing something that allocates a reserved tile (such as looking into a viewscreen), then loading another map where the tilesiz* of TILE_VIEWSCR is restored to 0. git-svn-id: https://svn.eduke32.com/eduke32@4259 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index dfbde3cf6..6218a8349 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -9738,20 +9738,21 @@ static void E_RecalcPicSiz(void) } #define RESTORE_MAPART_ARRAY(origar, bakar) do { \ - Bmemcpy(origar, bakar, sizeof(origar)); \ + EDUKE32_STATIC_ASSERT(sizeof(origar[0]) == sizeof(bakar[0])); \ + Bmemcpy(origar, bakar, MAXUSERTILES*sizeof(origar[0])); \ DO_FREE_AND_NULL(bakar); \ } while (0) // Allocate per-map ART backup array and back up the original! #define ALLOC_MAPART_ARRAY(origar, bakar) do { \ - bakar = Bmalloc(sizeof(origar)); \ + bakar = Bmalloc(MAXUSERTILES*sizeof(origar[0])); \ if (bakar == NULL) \ { \ initprintf("OUT OF MEMORY allocating per-map ART backup arrays!\n"); \ uninitengine(); \ exit(12); \ } \ - Bmemcpy(bakar, origar, sizeof(origar)); \ + Bmemcpy(bakar, origar, MAXUSERTILES*sizeof(origar[0])); \ } while (0) void E_MapArt_Clear(void)