Skip to content

Commit bfb6462

Browse files
committed
Upgraded PCRE to 8.10, fixed possible memory leak in PCRE
1 parent 5a747a4 commit bfb6462

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

pcre/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ them both to 0; an emulation function will be used. */
5252
#define HAVE_DLFCN_H 1
5353

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

5757
/* Define to 1 if you have the <limits.h> header file. */
5858
#define HAVE_LIMITS_H 1

pcre/readme.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
PCRE built as follows:
22

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

5-
2. Unzip and untar the file (eg.):
6-
7-
tar xjf pcre-8.01.tar.bz2
5+
2. Unzip the file pcre-8.10.zip
86

97

108
3. Copy the following files to the mushclient source "pcre" directory:

regexp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ pcre_extra * extra;
2929
extra = pcre_study(program, 0, &error);
3030

3131
if (error)
32+
{
33+
pcre_free (program);
3234
ThrowErrorException("Regexp study failed: %s", error);
35+
}
3336

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

37-
if (!re)
38-
ThrowErrorException("Could not allocate memory for regular expression");
39-
4040
// remember program and extra stuff
4141
re->m_program = program;
4242
re->m_extra = extra;
@@ -81,7 +81,7 @@ LARGE_INTEGER start,
8181
// free program as an indicator that we can't keep trying to do this one
8282
if (count <= 0)
8383
{
84-
free (prog->m_program);
84+
pcre_free (prog->m_program);
8585
prog->m_program = NULL;
8686
prog->m_iExecutionError = count; // remember reason
8787
}
@@ -118,7 +118,7 @@ pcre * program;
118118

119119
if (program)
120120
{
121-
free (program);
121+
pcre_free (program);
122122
return true; // good
123123
}
124124

regexp.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ class t_regexp
3939
}; // constructor
4040
~t_regexp () {
4141
if (m_program)
42-
free (m_program);
42+
pcre_free (m_program);
4343
if (m_extra)
44-
free (m_extra);
44+
pcre_free (m_extra);
4545
}; // destructor
4646

47-
// const char *startp [MAX_WILDCARDS];
48-
// const char *endp [MAX_WILDCARDS];
49-
5047
// pairs of offsets from match
5148
vector<int> m_vOffsets;
5249
// count of matches
@@ -86,7 +83,6 @@ class t_regexp
8683
iNumber = PCRE_ERROR_NOSUBSTRING;
8784
else
8885
iNumber = njg_get_first_set (m_program, sName.c_str (), &m_vOffsets [0]);
89-
// iNumber = pcre_get_stringnumber (m_program, sName.c_str ());
9086
}
9187
return GetWildcard (iNumber);
9288
}

0 commit comments

Comments
 (0)