From e38a487d56ee5fc2747d08441e81eaebaa9ab7dd Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 15 Nov 2026 14:50:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Free=20the=20block=20parts=20whe?= =?UTF-8?q?n=20loading=20corrupt=20map=20data=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A failed block creation leaked the already constructed halves and the index. --- Server/ULandscape.pas | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Server/ULandscape.pas b/Server/ULandscape.pas index bf18df4..9c920c2 100644 --- a/Server/ULandscape.pas +++ b/Server/ULandscape.pas @@ -538,15 +538,25 @@ var index: TGenericIndex; begin FMap.Position := ((AX * FHeight) + AY) * 196; - map := TMapBlock.Create(FMap, AX, AY); + map := nil; + statics := nil; + index := nil; + try + map := TMapBlock.Create(FMap, AX, AY); - FStaIdx.Position := ((AX * FHeight) + AY) * 12; - index := TGenericIndex.Create(FStaIdx); - statics := TSeperatedStaticBlock.Create(FStatics, index, AX, AY); - statics.TiledataProvider := FTiledataProvider; - index.Free; - - Result := TBlock.Create(map, statics); + FStaIdx.Position := ((AX * FHeight) + AY) * 12; + index := TGenericIndex.Create(FStaIdx); + statics := TSeperatedStaticBlock.Create(FStatics, index, AX, AY); + statics.TiledataProvider := FTiledataProvider; + index.Free; + + Result := TBlock.Create(map, statics); + except + map.Free; + statics.Free; + index.Free; + raise; + end; FBlockCache.StoreID(GetID(AX, AY), Result); end;