From 4188fb6ac75bc4d6dd8154d25442e35245315e3b Mon Sep 17 00:00:00 2001 From: Tinny Ng <tng@apache.org> Date: Tue, 9 Oct 2001 12:20:25 +0000 Subject: [PATCH] Leak fix: Need to delete fMatch if adopted. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173080 13f79535-47bb-0310-9956-ffa450edef68 --- src/util/regx/RegularExpression.cpp | 8 ++++++++ src/util/regx/RegularExpression.hpp | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/util/regx/RegularExpression.cpp b/src/util/regx/RegularExpression.cpp index 184b2b0c8..193073da7 100644 --- a/src/util/regx/RegularExpression.cpp +++ b/src/util/regx/RegularExpression.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2001/10/09 12:20:25 tng + * Leak fix: Need to delete fMatch if adopted. + * * Revision 1.4 2001/05/11 21:50:58 knoaman * Schema updates and fixes. * @@ -155,6 +158,8 @@ void RegularExpression::Context::reset(const XMLCh* const string fLimit = limit; fLength = fLimit - fStart; fInUse = true; + if (fAdoptMatch) + delete fMatch; fMatch = 0; if (fOffsets == 0 || fSize != noClosures) { @@ -439,6 +444,8 @@ bool RegularExpression::matches(const XMLCh* const expression, const int start, adoptMatch = true; } + if (context->fAdoptMatch) + delete context->fMatch; context->fMatch = lMatch; context->fAdoptMatch = adoptMatch; @@ -1302,3 +1309,4 @@ unsigned short RegularExpression::getCharType(const XMLCh ch) { /** * End of file RegularExpression.cpp */ + diff --git a/src/util/regx/RegularExpression.hpp b/src/util/regx/RegularExpression.hpp index a211fe83e..2c95311cd 100644 --- a/src/util/regx/RegularExpression.hpp +++ b/src/util/regx/RegularExpression.hpp @@ -112,11 +112,6 @@ public: static const unsigned short WT_LETTER; static const unsigned short WT_OTHER; - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setPattern(const XMLCh* const pattern, const XMLCh* const options=0); - // ----------------------------------------------------------------------- // Public Helper methods // ----------------------------------------------------------------------- @@ -178,6 +173,11 @@ private: // ----------------------------------------------------------------------- void cleanUp(); + // ----------------------------------------------------------------------- + // Setter methods + // ----------------------------------------------------------------------- + void setPattern(const XMLCh* const pattern, const XMLCh* const options=0); + // ----------------------------------------------------------------------- // Private Helper methods // ----------------------------------------------------------------------- -- GitLab