From a2c02a8c2f42dcd76e0cf6458f14afd642746dd5 Mon Sep 17 00:00:00 2001 From: Matthew Weber Date: Thu, 14 Oct 2021 10:33:25 -0500 Subject: [PATCH] package/xerces: fix memory leak when transcoding fails Seen with the IconvGNU transcoder when parsing " Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- ...oadMsg-fix-memory-leak-when-transcod.patch | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 package/xerces/0002-InMemMsgLoader-loadMsg-fix-memory-leak-when-transcod.patch diff --git a/package/xerces/0002-InMemMsgLoader-loadMsg-fix-memory-leak-when-transcod.patch b/package/xerces/0002-InMemMsgLoader-loadMsg-fix-memory-leak-when-transcod.patch new file mode 100644 index 0000000000..76b37c63d9 --- /dev/null +++ b/package/xerces/0002-InMemMsgLoader-loadMsg-fix-memory-leak-when-transcod.patch @@ -0,0 +1,87 @@ +From 1bdf6d8ba878c1fe1d779824be70001fc0bebd2c Mon Sep 17 00:00:00 2001 +From: Even Rouault +Date: Fri, 27 Aug 2021 01:33:27 +0200 +Subject: [PATCH] InMemMsgLoader::loadMsg(): fix memory leak when transcoding + fails. + +Seen with the IconvGNU transcoder when parsing " + +--- + .../MsgLoaders/InMemory/InMemMsgLoader.cpp | 31 ++++++++++++++----- + 1 file changed, 23 insertions(+), 8 deletions(-) + +diff --git a/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp b/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp +index cda103226..6971fde96 100644 +--- a/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp ++++ b/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp +@@ -25,6 +25,7 @@ + // --------------------------------------------------------------------------- + #include + #include ++#include + #include + #include + #include +@@ -153,14 +154,28 @@ bool InMemMsgLoader::loadMsg(const XMLMsgLoader::XMLMsgId msgToLoad + XMLCh* tmp4 = 0; + + bool bRet = false; +- if (repText1) +- tmp1 = XMLString::transcode(repText1, manager); +- if (repText2) +- tmp2 = XMLString::transcode(repText2, manager); +- if (repText3) +- tmp3 = XMLString::transcode(repText3, manager); +- if (repText4) +- tmp4 = XMLString::transcode(repText4, manager); ++ try ++ { ++ if (repText1) ++ tmp1 = XMLString::transcode(repText1, manager); ++ if (repText2) ++ tmp2 = XMLString::transcode(repText2, manager); ++ if (repText3) ++ tmp3 = XMLString::transcode(repText3, manager); ++ if (repText4) ++ tmp4 = XMLString::transcode(repText4, manager); ++ } ++ catch( const TranscodingException& ) ++ { ++ if (tmp1) ++ manager->deallocate(tmp1); ++ if (tmp2) ++ manager->deallocate(tmp2); ++ if (tmp3) ++ manager->deallocate(tmp3); ++ // Note: tmp4 cannot leak ++ throw; ++ } + + bRet = loadMsg(msgToLoad, toFill, maxChars, tmp1, tmp2, tmp3, tmp4, manager); + +-- +2.17.1 +