From 99c2460976bf0d80b13acf20be5595466a3b5014 Mon Sep 17 00:00:00 2001 From: Joseph Rafael Ferrer Date: Thu, 19 Jan 2023 22:46:26 +0800 Subject: [PATCH] Fix FreeImage memleaks --- Common/UtilNPP/ImageIO.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Common/UtilNPP/ImageIO.h b/Common/UtilNPP/ImageIO.h index 75e1e37c7..9789acdaa 100644 --- a/Common/UtilNPP/ImageIO.h +++ b/Common/UtilNPP/ImageIO.h @@ -96,6 +96,9 @@ namespace npp // swap the user given image with our result image, effecively // moving our newly loaded image data into the user provided shell oImage.swap(rImage); + + // unloads the image loaded by FreeImage_Load + FreeImage_Unload(pBitmap); } // Save an gray-scale image to disk. @@ -122,6 +125,9 @@ namespace npp bool bSuccess; bSuccess = FreeImage_Save(FIF_PGM, pResultBitmap, rFileName.c_str(), 0) == TRUE; NPP_ASSERT_MSG(bSuccess, "Failed to save result image."); + + // unloads the image loaded by FreeImage_Allocate + FreeImage_Unload(pBitmap); } // Load a gray-scale image from disk.