From dc407afacff397482916e8ac860f937cfe0a84b6 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 31 Jul 2013 09:54:08 +0100 Subject: Fixes a memory leak in the LoadImage_PNG() function. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PNG Reader Class was never freed. Thanks to Leonardo M. Ramé for reporting this. --- src/corelib/fpg_imgfmt_png.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/fpg_imgfmt_png.pas b/src/corelib/fpg_imgfmt_png.pas index c95150e4..d9683bbe 100644 --- a/src/corelib/fpg_imgfmt_png.pas +++ b/src/corelib/fpg_imgfmt_png.pas @@ -68,6 +68,7 @@ end; function LoadImage_PNG(const AFileName: TfpgString): TfpgImage; var imga: TFPCustomImage; + PNGReader: TFPReaderPNG; begin Result := nil; if not fpgFileExists(AFileName) then @@ -75,7 +76,12 @@ begin imga := TFPMemoryImage.Create(0, 0); try - imga.LoadFromFile(AFileName, TFPReaderPNG.Create); // auto size image + PNGReader := TFPReaderPNG.Create; + try + imga.LoadFromFile(AFileName, PNGReader); // auto size image + finally + PNGReader.Free; + end; except imga := nil; end; -- cgit v1.2.3-70-g09d2