summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-05-21 16:28:11 +0200
committerBram Moolenaar <Bram@vim.org>2013-05-21 16:28:11 +0200
commitb09d983c78b27362a662ea9ce40e9092d5678bd0 (patch)
tree4163b9ad5ab3711ae55bccea090c3287b801c93f
parent12e4014092cae21d9fd914ee0fa3a09b51eacaab (diff)
downloadvim-git-7.3.990.tar.gz
updated for version 7.3.990v7.3.990
Problem: Memory leak in new regexp engine. Solution: Jump to end of function to free memory. (Dominique Pelle)
-rw-r--r--src/regexp_nfa.c39
-rw-r--r--src/version.c2
2 files changed, 23 insertions, 18 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 297829a1d..a9b5cfe3c 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -2143,6 +2143,7 @@ post2nfa(postfix, end, nfa_calc_size)
nfa_state_T *s;
nfa_state_T *s1;
nfa_state_T *matchstate;
+ nfa_state_T *ret = NULL;
if (postfix == NULL)
return NULL;
@@ -2211,7 +2212,7 @@ post2nfa(postfix, end, nfa_calc_size)
e1 = POP();
s = new_state(NFA_SPLIT, e1.start, e2.start);
if (s == NULL)
- return NULL;
+ goto theend;
PUSH(frag(s, append(e1.out, e2.out)));
break;
@@ -2225,7 +2226,7 @@ post2nfa(postfix, end, nfa_calc_size)
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
- return NULL;
+ goto theend;
patch(e.out, s);
PUSH(frag(s, list1(&s->out1)));
break;
@@ -2240,7 +2241,7 @@ post2nfa(postfix, end, nfa_calc_size)
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
- return NULL;
+ goto theend;
PUSH(frag(s, append(e.out, list1(&s->out1))));
break;
@@ -2254,7 +2255,7 @@ post2nfa(postfix, end, nfa_calc_size)
e = POP();
s = new_state(NFA_SPLIT, NULL, e.start);
if (s == NULL)
- return NULL;
+ goto theend;
PUSH(frag(s, append(e.out, list1(&s->out))));
break;
@@ -2268,7 +2269,7 @@ post2nfa(postfix, end, nfa_calc_size)
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
- return NULL;
+ goto theend;
patch(e.out, s);
PUSH(frag(e.start, list1(&s->out1)));
break;
@@ -2283,7 +2284,7 @@ post2nfa(postfix, end, nfa_calc_size)
}
s = new_state(NFA_SKIP_CHAR, NULL, NULL);
if (s == NULL)
- return NULL;
+ goto theend;
PUSH(frag(s, list1(&s->out)));
break;
@@ -2293,7 +2294,7 @@ post2nfa(postfix, end, nfa_calc_size)
* END_INVISIBLE, similarly to MOPEN.
*/
/* TODO: Maybe this drops the speed? */
- return NULL;
+ goto theend;
if (nfa_calc_size == TRUE)
{
@@ -2303,12 +2304,12 @@ post2nfa(postfix, end, nfa_calc_size)
e = POP();
s1 = new_state(NFA_END_INVISIBLE, NULL, NULL);
if (s1 == NULL)
- return NULL;
+ goto theend;
patch(e.out, s1);
s = new_state(NFA_START_INVISIBLE, e.start, s1);
if (s == NULL)
- return NULL;
+ goto theend;
PUSH(frag(s, list1(&s1->out)));
break;
@@ -2357,10 +2358,10 @@ post2nfa(postfix, end, nfa_calc_size)
{
s = new_state(mopen, NULL, NULL);
if (s == NULL)
- return NULL;
+ goto theend;
s1 = new_state(mclose, NULL, NULL);
if (s1 == NULL)
- return NULL;
+ goto theend;
patch(list1(&s->out), s1);
PUSH(frag(s, list1(&s1->out)));
break;
@@ -2371,11 +2372,11 @@ post2nfa(postfix, end, nfa_calc_size)
e = POP();
s = new_state(mopen, e.start, NULL); /* `(' */
if (s == NULL)
- return NULL;
+ goto theend;
s1 = new_state(mclose, NULL, NULL); /* `)' */
if (s1 == NULL)
- return NULL;
+ goto theend;
patch(e.out, s1);
if (mopen == NFA_MULTIBYTE || mopen == NFA_COMPOSING)
@@ -2397,7 +2398,7 @@ post2nfa(postfix, end, nfa_calc_size)
}
s = new_state(*p, NULL, NULL);
if (s == NULL)
- return NULL;
+ goto theend;
PUSH(frag(s, list1(&s->out)));
break;
@@ -2408,7 +2409,7 @@ post2nfa(postfix, end, nfa_calc_size)
if (nfa_calc_size == TRUE)
{
nstate++;
- return NULL; /* Return value when counting size is ignored anyway */
+ goto theend; /* Return value when counting size is ignored anyway */
}
e = POP();
@@ -2418,14 +2419,16 @@ post2nfa(postfix, end, nfa_calc_size)
if (istate >= nstate)
EMSG_RET_NULL(_("E876: (NFA regexp) Not enough space to store the whole NFA "));
- vim_free(stack);
-
matchstate = &state_ptr[istate++]; /* the match state */
matchstate->c = NFA_MATCH;
matchstate->out = matchstate->out1 = NULL;
patch(e.out, matchstate);
- return e.start;
+ ret = e.start;
+
+theend:
+ vim_free(stack);
+ return ret;
#undef POP1
#undef PUSH1
diff --git a/src/version.c b/src/version.c
index 9ff699d2d..4cec52add 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 990,
+/**/
989,
/**/
988,