From 2b85c7e0b90a12c9b3dd55f4fb4dd2fbb8b30edc Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 15 Feb 2011 15:46:16 +1300 Subject: [PATCH] fix stack overflow in Map.Resize() --- OpenRA.Game/Map.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index d44a0a89cf..391a896a7a 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -417,9 +417,12 @@ namespace OpenRA } public void Resize(int width, int height) // editor magic. - { - MapTiles = Lazy.New(() => ResizeArray(MapTiles.Value, MapTiles.Value[0, 0], width, height)); - MapResources = Lazy.New(() => ResizeArray(MapResources.Value, MapResources.Value[0, 0], width, height)); + { + var oldMapTiles = MapTiles.Value; + var oldMapResources = MapResources.Value; + + MapTiles = Lazy.New(() => ResizeArray(oldMapTiles, oldMapTiles[0, 0], width, height)); + MapResources = Lazy.New(() => ResizeArray(oldMapResources, oldMapResources[0, 0], width, height)); MapSize = new int2(width, height); }