fix m_Matches overflow if Compile() is called more than once (bug 742236)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20733 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -73,17 +73,33 @@ private:
|
|||||||
// return the string containing the error message for the given err code
|
// return the string containing the error message for the given err code
|
||||||
wxString GetErrorMsg(int errorcode) const;
|
wxString GetErrorMsg(int errorcode) const;
|
||||||
|
|
||||||
|
// init the members
|
||||||
|
void Init()
|
||||||
|
{
|
||||||
|
m_isCompiled = FALSE;
|
||||||
|
m_Matches = NULL;
|
||||||
|
m_nMatches = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// free the RE if compiled
|
// free the RE if compiled
|
||||||
void Free()
|
void Free()
|
||||||
{
|
{
|
||||||
if ( IsValid() )
|
if ( IsValid() )
|
||||||
{
|
{
|
||||||
regfree(&m_RegEx);
|
regfree(&m_RegEx);
|
||||||
|
}
|
||||||
|
|
||||||
m_isCompiled = FALSE;
|
delete [] m_Matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// free the RE if any and reinit the members
|
||||||
|
void Reinit()
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// compiled RE
|
// compiled RE
|
||||||
regex_t m_RegEx;
|
regex_t m_RegEx;
|
||||||
|
|
||||||
@@ -105,16 +121,12 @@ private:
|
|||||||
|
|
||||||
wxRegExImpl::wxRegExImpl()
|
wxRegExImpl::wxRegExImpl()
|
||||||
{
|
{
|
||||||
m_isCompiled = FALSE;
|
Init();
|
||||||
m_Matches = NULL;
|
|
||||||
m_nMatches = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegExImpl::~wxRegExImpl()
|
wxRegExImpl::~wxRegExImpl()
|
||||||
{
|
{
|
||||||
Free();
|
Free();
|
||||||
|
|
||||||
delete [] m_Matches;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRegExImpl::GetErrorMsg(int errorcode) const
|
wxString wxRegExImpl::GetErrorMsg(int errorcode) const
|
||||||
@@ -149,7 +161,7 @@ wxString wxRegExImpl::GetErrorMsg(int errorcode) const
|
|||||||
|
|
||||||
bool wxRegExImpl::Compile(const wxString& expr, int flags)
|
bool wxRegExImpl::Compile(const wxString& expr, int flags)
|
||||||
{
|
{
|
||||||
Free();
|
Reinit();
|
||||||
|
|
||||||
// translate our flags to regcomp() ones
|
// translate our flags to regcomp() ones
|
||||||
wxASSERT_MSG( !(flags &
|
wxASSERT_MSG( !(flags &
|
||||||
|
Reference in New Issue
Block a user