🐛 Free the config document on validation failures

Invalid or outdated configuration leaked the parsed XML document
while aborting startup.
This commit is contained in:
2026-11-15 22:08:32 +01:00
parent 5910178309
commit 45386dcbaf
+4 -2
View File
@@ -203,6 +203,7 @@ begin
inherited Create; inherited Create;
FFilename := AFilename; FFilename := AFilename;
ReadXMLFile(xmlDoc, AFilename); ReadXMLFile(xmlDoc, AFilename);
try
version := 0; version := 0;
if not ((xmlDoc.DocumentElement.NodeName = 'CEDConfig') and if not ((xmlDoc.DocumentElement.NodeName = 'CEDConfig') and
TryStrToInt(xmlDoc.DocumentElement.AttribStrings['Version'], version) and TryStrToInt(xmlDoc.DocumentElement.AttribStrings['Version'], version) and
@@ -236,9 +237,10 @@ begin
else else
FMapStates := TMapStates.Create(Self); FMapStates := TMapStates.Create(Self);
xmlDoc.Free;
FChanged := False; FChanged := False;
finally
xmlDoc.Free;
end;
end; end;
constructor TConfig.Init(AFilename: string); constructor TConfig.Init(AFilename: string);