diff options
author | Frankie Dintino <fdintino@theatlantic.com> | 2016-06-16 17:55:27 -0400 |
---|---|---|
committer | Frankie Dintino <fdintino@theatlantic.com> | 2016-06-16 17:55:27 -0400 |
commit | 7da26e718eed1d156fc4d6f507696487b920c2cf (patch) | |
tree | edee0efc5b7c3b6e0265e16fbb12f22af855257d | |
parent | 664d0a110559205e61a0aec3a8f003bac13ab500 (diff) |
webp-handler: Fix memory leak
-rw-r--r-- | XMPFiles/source/FileHandlers/WEBP_Handler.cpp | 10 | ||||
-rw-r--r-- | XMPFiles/source/FileHandlers/WEBP_Handler.hpp | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/XMPFiles/source/FileHandlers/WEBP_Handler.cpp b/XMPFiles/source/FileHandlers/WEBP_Handler.cpp index 498f5c6..2a4cdeb 100644 --- a/XMPFiles/source/FileHandlers/WEBP_Handler.cpp +++ b/XMPFiles/source/FileHandlers/WEBP_Handler.cpp @@ -58,6 +58,10 @@ WEBP_MetaHandler::~WEBP_MetaHandler() delete this->mainChunk; if (this->exifMgr) delete this->exifMgr; + if (this->iptcMgr) + delete this->iptcMgr; + if (this->psirMgr) + delete this->psirMgr; } void WEBP_MetaHandler::CacheFileData() @@ -101,6 +105,8 @@ void WEBP_MetaHandler::ProcessXMP() else { this->exifMgr = new TIFF_FileWriter(); } + this->psirMgr = new PSIR_MemoryReader(); + this->iptcMgr = new IPTC_Reader(); if (this->parent) { exifMgr->SetErrorCallback(&this->parent->errorCallback); } @@ -123,8 +129,8 @@ void WEBP_MetaHandler::ProcessXMP() if (this->containsXMP) options |= k2XMP_FileHadXMP; TIFF_Manager& exif = *this->exifMgr; - PSIR_Manager& psir = *(new PSIR_MemoryReader()); - IPTC_Manager& iptc = *(new IPTC_Reader()); + PSIR_Manager& psir = *this->psirMgr; + IPTC_Manager& iptc = *this->iptcMgr; ImportPhotoData(exif, iptc, psir, kDigestMatches, &this->xmpObj, options); // Assume that, since the file had EXIF data, some of it was mapped to diff --git a/XMPFiles/source/FileHandlers/WEBP_Handler.hpp b/XMPFiles/source/FileHandlers/WEBP_Handler.hpp index 7fa59d3..52c5e7c 100644 --- a/XMPFiles/source/FileHandlers/WEBP_Handler.hpp +++ b/XMPFiles/source/FileHandlers/WEBP_Handler.hpp @@ -6,6 +6,8 @@ #include "XMPFiles/source/FormatSupport/WEBP_Support.hpp" #include "XMPFiles/source/FormatSupport/TIFF_Support.hpp" +#include "XMPFiles/source/FormatSupport/IPTC_Support.hpp" +#include "XMPFiles/source/FormatSupport/PSIR_Support.hpp" #include "source/XIO.hpp" @@ -35,7 +37,11 @@ public: WEBP::XMPChunk* xmpChunk; XMP_Int64 initialFileSize; TIFF_Manager* exifMgr; - + // The PSIR_Manager and IPTC_Manager aren't actually used, but they need + // to be instantiated and passed to the function that reconciles EXIF and + // XMP data. + PSIR_Manager* psirMgr; + IPTC_Manager* iptcMgr; }; #endif /* __WEBP_Handler_hpp__ */ |