From b996f92c282162596f8a48d5b8d961759579669b Mon Sep 17 00:00:00 2001 From: terminx Date: Fri, 12 Aug 2011 15:40:28 +0000 Subject: [PATCH] Fix gamearray overallocation on 64-bit... was being allocated as (array size * sizeof(intptr_t)) when the struct actually contains a ptr to a block of int32_t git-svn-id: https://svn.eduke32.com/eduke32@1964 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gamevars.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 429019fb1..3f6f46518 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -159,8 +159,8 @@ int32_t Gv_ReadSave(int32_t fil, int32_t newbehav) if (kdfread(aGameArrays[i].szLabel,sizeof(uint8_t) * MAXARRAYLABEL, 1, fil) != 1) goto corrupt; hash_add(&h_arrays, aGameArrays[i].szLabel, i, 1); - aGameArrays[i].plValues=Bcalloc(aGameArrays[i].size,sizeof(intptr_t)); - if (kdfread(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil) < 1) goto corrupt; + aGameArrays[i].plValues=Bcalloc(aGameArrays[i].size,sizeof(int32_t)); + if (kdfread(aGameArrays[i].plValues,sizeof(int32_t) * aGameArrays[i].size, 1, fil) < 1) goto corrupt; } // Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); @@ -273,7 +273,7 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav) { dfwrite(&(aGameArrays[i]),sizeof(gamearray_t),1,fil); dfwrite(aGameArrays[i].szLabel,sizeof(uint8_t) * MAXARRAYLABEL, 1, fil); - dfwrite(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil); + dfwrite(aGameArrays[i].plValues,sizeof(int32_t) * aGameArrays[i].size, 1, fil); } G_Util_PtrToIdx(apScriptGameEvent, MAXGAMEEVENTS, script, P2I_FWD_NON0); @@ -411,10 +411,10 @@ int32_t Gv_NewArray(const char *pszLabel, int32_t asize) i = g_gameArrayCount; if (aGameArrays[i].szLabel == NULL) - aGameArrays[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(uint8_t)); + aGameArrays[i].szLabel=(char *)Bcalloc(MAXVARLABEL,sizeof(uint8_t)); if (aGameArrays[i].szLabel != pszLabel) Bstrcpy(aGameArrays[i].szLabel,pszLabel); - aGameArrays[i].plValues=Bcalloc(asize,sizeof(intptr_t)); + aGameArrays[i].plValues=(int32_t *)Bcalloc(asize,sizeof(int32_t)); aGameArrays[i].size=asize; aGameArrays[i].bReset=0; g_gameArrayCount++;