[fpc-devel] XMLCfg leaking

Ales Katona ales at chello.sk
Sun Feb 6 18:30:20 CET 2005


Try this program with a corrupted xml file(just delte part of a tag or 
something)
Compile with -ghl and you'll get a few bytes leaked.

program xmltest;

{$mode objfpc}{$H+}

uses
  SysUtils, XMLCfg;
 
function LoadXML(var axml: TXmlConfig; const filename: string): boolean;
begin
  writeln('Loading');
  axml:=nil;
  result:=true;
  try
    axml:=TXMlConfig.Create(filename); // try to parse the file
  except
    on E: Exception do
      begin
        writeln('Error: '+ E.Message);
        result:=false;
      end;
  end;
  if not result then
    freeandnil(axml);
end;

var xml: TXMLConfig;
begin
  if LoadXML(xml, 'test.xml') then
    writeln('Success');
end.




More information about the fpc-devel mailing list