To: vim_dev@googlegroups.com
Subject: Patch 7.3.990
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.3.990
Problem: Memory leak in new regexp engine.
Solution: Jump to end of function to free memory. (Dominique Pelle)
Files: src/regexp_nfa.c
*** ../vim-7.3.989/src/regexp_nfa.c 2013-05-21 15:33:37.000000000 +0200
--- src/regexp_nfa.c 2013-05-21 16:17:15.000000000 +0200
***************
*** 2143,2148 ****
--- 2143,2149 ----
nfa_state_T *s;
nfa_state_T *s1;
nfa_state_T *matchstate;
+ nfa_state_T *ret = NULL;
if (postfix == NULL)
return NULL;
***************
*** 2211,2217 ****
e1 = POP();
s = new_state(NFA_SPLIT, e1.start, e2.start);
if (s == NULL)
! return NULL;
PUSH(frag(s, append(e1.out, e2.out)));
break;
--- 2212,2218 ----
e1 = POP();
s = new_state(NFA_SPLIT, e1.start, e2.start);
if (s == NULL)
! goto theend;
PUSH(frag(s, append(e1.out, e2.out)));
break;
***************
*** 2225,2231 ****
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
! return NULL;
patch(e.out, s);
PUSH(frag(s, list1(&s->out1)));
break;
--- 2226,2232 ----
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
! goto theend;
patch(e.out, s);
PUSH(frag(s, list1(&s->out1)));
break;
***************
*** 2240,2246 ****
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
! return NULL;
PUSH(frag(s, append(e.out, list1(&s->out1))));
break;
--- 2241,2247 ----
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
! goto theend;
PUSH(frag(s, append(e.out, list1(&s->out1))));
break;
***************
*** 2254,2260 ****
e = POP();
s = new_state(NFA_SPLIT, NULL, e.start);
if (s == NULL)
! return NULL;
PUSH(frag(s, append(e.out, list1(&s->out))));
break;
--- 2255,2261 ----
e = POP();
s = new_state(NFA_SPLIT, NULL, e.start);
if (s == NULL)
! goto theend;
PUSH(frag(s, append(e.out, list1(&s->out))));
break;
***************
*** 2268,2274 ****
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
! return NULL;
patch(e.out, s);
PUSH(frag(e.start, list1(&s->out1)));
break;
--- 2269,2275 ----
e = POP();
s = new_state(NFA_SPLIT, e.start, NULL);
if (s == NULL)
! goto theend;
patch(e.out, s);
PUSH(frag(e.start, list1(&s->out1)));
break;
***************
*** 2283,2289 ****
}
s = new_state(NFA_SKIP_CHAR, NULL, NULL);
if (s == NULL)
! return NULL;
PUSH(frag(s, list1(&s->out)));
break;
--- 2284,2290 ----
}
s = new_state(NFA_SKIP_CHAR, NULL, NULL);
if (s == NULL)
! goto theend;
PUSH(frag(s, list1(&s->out)));
break;
***************
*** 2293,2299 ****
* END_INVISIBLE, similarly to MOPEN.
*/
/* TODO: Maybe this drops the speed? */
! return NULL;
if (nfa_calc_size == TRUE)
{
--- 2294,2300 ----
* END_INVISIBLE, similarly to MOPEN.
*/
/* TODO: Maybe this drops the speed? */
! goto theend;
if (nfa_calc_size == TRUE)
{
***************
*** 2303,2314 ****
e = POP();
s1 = new_state(NFA_END_INVISIBLE, NULL, NULL);
if (s1 == NULL)
! return NULL;
patch(e.out, s1);
s = new_state(NFA_START_INVISIBLE, e.start, s1);
if (s == NULL)
! return NULL;
PUSH(frag(s, list1(&s1->out)));
break;
--- 2304,2315 ----
e = POP();
s1 = new_state(NFA_END_INVISIBLE, NULL, NULL);
if (s1 == NULL)
! goto theend;
patch(e.out, s1);
s = new_state(NFA_START_INVISIBLE, e.start, s1);
if (s == NULL)
! goto theend;
PUSH(frag(s, list1(&s1->out)));
break;
***************
*** 2357,2366 ****
{
s = new_state(mopen, NULL, NULL);
if (s == NULL)
! return NULL;
s1 = new_state(mclose, NULL, NULL);
if (s1 == NULL)
! return NULL;
patch(list1(&s->out), s1);
PUSH(frag(s, list1(&s1->out)));
break;
--- 2358,2367 ----
{
s = new_state(mopen, NULL, NULL);
if (s == NULL)
! goto theend;
s1 = new_state(mclose, NULL, NULL);
if (s1 == NULL)
! goto theend;
patch(list1(&s->out), s1);
PUSH(frag(s, list1(&s1->out)));
break;
***************
*** 2371,2381 ****
e = POP();
s = new_state(mopen, e.start, NULL); /* `(' */
if (s == NULL)
! return NULL;
s1 = new_state(mclose, NULL, NULL); /* `)' */
if (s1 == NULL)
! return NULL;
patch(e.out, s1);
if (mopen == NFA_MULTIBYTE || mopen == NFA_COMPOSING)
--- 2372,2382 ----
e = POP();
s = new_state(mopen, e.start, NULL); /* `(' */
if (s == NULL)
! goto theend;
s1 = new_state(mclose, NULL, NULL); /* `)' */
if (s1 == NULL)
! goto theend;
patch(e.out, s1);
if (mopen == NFA_MULTIBYTE || mopen == NFA_COMPOSING)
***************
*** 2397,2403 ****
}
s = new_state(*p, NULL, NULL);
if (s == NULL)
! return NULL;
PUSH(frag(s, list1(&s->out)));
break;
--- 2398,2404 ----
}
s = new_state(*p, NULL, NULL);
if (s == NULL)
! goto theend;
PUSH(frag(s, list1(&s->out)));
break;
***************
*** 2408,2414 ****
if (nfa_calc_size == TRUE)
{
nstate++;
! return NULL; /* Return value when counting size is ignored anyway */
}
e = POP();
--- 2409,2415 ----
if (nfa_calc_size == TRUE)
{
nstate++;
! goto theend; /* Return value when counting size is ignored anyway */
}
e = POP();
***************
*** 2418,2431 ****
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;
#undef POP1
#undef PUSH1
--- 2419,2434 ----
if (istate >= nstate)
EMSG_RET_NULL(_("E876: (NFA regexp) Not enough space to store the whole NFA "));
matchstate = &state_ptr[istate++]; /* the match state */
matchstate->c = NFA_MATCH;
matchstate->out = matchstate->out1 = NULL;
patch(e.out, matchstate);
! ret = e.start;
!
! theend:
! vim_free(stack);
! return ret;
#undef POP1
#undef PUSH1
*** ../vim-7.3.989/src/version.c 2013-05-21 15:33:37.000000000 +0200
--- src/version.c 2013-05-21 16:18:03.000000000 +0200
***************
*** 730,731 ****
--- 730,733 ----
{ /* Add new patch number below this line */
+ /**/
+ 990,
/**/
--
This message contains 78% recycled characters.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///