🐛 Free the config document on validation failures
Invalid or outdated configuration leaked the parsed XML document while aborting startup.
This commit is contained in:
+4
-2
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user