Skip to content

Commit

Permalink
Upgraded PCRE to 8.10, fixed possible memory leak in PCRE
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jul 7, 2010
1 parent 5a747a4 commit bfb6462
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pcre/config.h
Expand Up @@ -52,7 +52,7 @@ them both to 0; an emulation function will be used. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
#define HAVE_INTTYPES_H 0

/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
Expand Down
6 changes: 2 additions & 4 deletions pcre/readme.txt
@@ -1,10 +1,8 @@
PCRE built as follows:

1. Download: http://sourceforge.net/projects/pcre/files/pcre/8.01/pcre-8.01.tar.bz2/download
1. Download: http://sourceforge.net/projects/pcre/files/pcre/8.10/pcre-8.10.zip/download

2. Unzip and untar the file (eg.):

tar xjf pcre-8.01.tar.bz2
2. Unzip the file pcre-8.10.zip


3. Copy the following files to the mushclient source "pcre" directory:
Expand Down
10 changes: 5 additions & 5 deletions regexp.cpp
Expand Up @@ -29,14 +29,14 @@ pcre_extra * extra;
extra = pcre_study(program, 0, &error);

if (error)
{
pcre_free (program);
ThrowErrorException("Regexp study failed: %s", error);
}

// we need to allocate memory for the substring offsets
re = new t_regexp;

if (!re)
ThrowErrorException("Could not allocate memory for regular expression");

// remember program and extra stuff
re->m_program = program;
re->m_extra = extra;
Expand Down Expand Up @@ -81,7 +81,7 @@ LARGE_INTEGER start,
// free program as an indicator that we can't keep trying to do this one
if (count <= 0)
{
free (prog->m_program);
pcre_free (prog->m_program);
prog->m_program = NULL;
prog->m_iExecutionError = count; // remember reason
}
Expand Down Expand Up @@ -118,7 +118,7 @@ pcre * program;

if (program)
{
free (program);
pcre_free (program);
return true; // good
}

Expand Down
8 changes: 2 additions & 6 deletions regexp.h
Expand Up @@ -39,14 +39,11 @@ class t_regexp
}; // constructor
~t_regexp () {
if (m_program)
free (m_program);
pcre_free (m_program);
if (m_extra)
free (m_extra);
pcre_free (m_extra);
}; // destructor

// const char *startp [MAX_WILDCARDS];
// const char *endp [MAX_WILDCARDS];

// pairs of offsets from match
vector<int> m_vOffsets;
// count of matches
Expand Down Expand Up @@ -86,7 +83,6 @@ class t_regexp
iNumber = PCRE_ERROR_NOSUBSTRING;
else
iNumber = njg_get_first_set (m_program, sName.c_str (), &m_vOffsets [0]);
// iNumber = pcre_get_stringnumber (m_program, sName.c_str ());
}
return GetWildcard (iNumber);
}
Expand Down

0 comments on commit bfb6462

Please sign in to comment.