lazreport: Memory leak on LoadFromXMLStream lazarus / 31-LCL ---------------------------------------------------------------------- bpranoto · 2021-05-24 03:17 Hi, I just found a memory leak in lr_class.pas method LoadFromXMLStream. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrReport.LoadFromXMLStream(const Stream: TStream);var  XML: TLrXMLConfig;begin  XML := TLrXMLConfig.Create(nil);  XML.LoadFromStream(Stream);  // <= MEMORY LEAK IF FAILS  try    LoadFromXML(XML, 'LazReport/');    FileName := '-stream-';  finally  XML.Free;  end;end;  Because the call of LoadFromStream() is outside the try..finally block, if XML.LoadFromStream(Stream) fails, the XML won't be freed, hence a memory leak occurs. How to reproduce the bug: 1. Compile the attached demo program with heap tracking on 2. Run the demo 3. Click the Show Error (an exception will raised) 4. Quit the program 5. If you run from IDE, check the debug windows => Console in/output I also attach the patch here. I've reported the bug here https://bugs.freepascal.org/view.php?id=38927 ---------------------------------------------------------------------- jamie · 2021-05-24 20:36 why don't you report it to the bug page ? ---------------------------------------------------------------------- bpranoto · 2021-05-25 05:52 I did. See the last sentence of my post. QuoteI've reported the bug here https://bugs.freepascal.org/view.php?id=38927