[fpc-pascal] Memory Leak's in XMLRead unit

Vojtěch Čihák vojtech.cihak at atlas.cz
Wed Nov 8 02:15:09 CET 2017


Hi,
if I run the code it writes "Unhandled exception". I tried to add another try..except block and it's OK. 
 
program xml_leak_test;
{$mode objfpc}
uses
  heaptrc,
  Classes,
  DOM,
  XMLRead;
var
  XMLDocument: TXMLDocument;
  InvalidStream: TStringStream;
 
const
  INVALID_XML_CONTENT = '<<<INVALID XML>>>';
 
begin
  SetHeapTraceOutput('heap.trc');
 
  XMLDocument := nil;
  InvalidStream := TStringStream.Create(INVALID_XML_CONTENT);
  try
    try
      ReadXMLFile(XMLDocument, InvalidStream);
    except
 
    end;
  finally
    InvalidStream.Free;
    XMLDocument.Free;
  end;
 
end.
 
Note: when I tried your original code in Lazaur method, it didn't leak at all.
 
V.
______________________________________________________________
 > Od: African Wild Dog <paintedlycaon at gmail.com>
 > Komu: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
 > Datum: 07.11.2017 23:19
 > Předmět: [fpc-pascal] Memory Leak's in XMLRead unit
 >
Hello,Using ReadXMLFile function from XMLRead unit generates memory leaks when trying to read a invalid XML content.....
 
 ----------
 
 _______________________________________________
 fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171108/4c913979/attachment.html>


More information about the fpc-pascal mailing list