- HackFix: Crash on maps with isolated entry points (by silversurfer)

o see http://www.ja-galaxy-forum.com/board/ubbthreads.php/topics/312260/Re_BUGZILLA_report_all_bugs_he.html#Post312260
o see http://www.ja-galaxy-forum.com/board/ubbthreads.php/topics/312612/Re_BUGZILLA_report_all_bugs_he.html#Post312612
o The main problem of the crash is, that some memory gets overwritten -> Workaround (hackfix): Increased the array for the map edgepoints to a fixed size of 400 so we can avoid the crash
o Of course this is not the best fix (because of increased memory usage), so if someone can improve the fix, do it :)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6240 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2013-07-25 08:38:43 +00:00
parent a5bbc40756
commit acf4968253
+8
View File
@@ -383,6 +383,13 @@ void InternallyClassifyEdgepoints( SOLDIERTYPE *pSoldier, INT32 sGridNo,
{
*psArray2 = (INT32*)MemAlloc( sizeof( INT32 ) * 400 );
}
// silversurfer: hackfix for crash on maps with isolated entry points
// we can't just keep adding data to psArray2 because it has only a fixed amount of memory available
// if we keep adding beyond that we overwrite foreign data!
// memory allocation for the real gps2nd<insert compass point here>EdgepointArray is done in function void GenerateMapEdgepoints(BOOLEAN fValidate)
// let's blow this up to some bigger amount, sizeof( INT32 ) * 400 will do for now
(*psArray2) = (INT32*)MemRealloc( (*psArray2), sizeof( INT32 ) * 400 );
for( i = 0; i < *pusArraySize1; i++ )
{
if( sGridNo == (*psArray1)[ i ] )
@@ -485,6 +492,7 @@ void InternallyClassifyEdgepoints( SOLDIERTYPE *pSoldier, INT32 sGridNo,
}
//Now compact the primary array, because some edgepoints have been removed.
CompactEdgepointArray( psArray1, pusMiddleIndex1, pusArraySize1 );
// silversurfer: this is the point where the editor will crash with a HeapValidate() error because we have been adding data beyond reserved memory
(*psArray2) = (INT32*)MemRealloc( (*psArray2), *pusArraySize2 * sizeof( INT32 ) );
}