From 50ab994ab34fcbe0046a9a998ee420be196334ba Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 13 Apr 2015 15:28:12 +0200 Subject: [PATCH] =?UTF-8?q?patch=207.4.696=20Problem:=20=20=20=20Not=20fre?= =?UTF-8?q?eing=20memory=20when=20encountering=20an=20error.=20Solution:?= =?UTF-8?q?=20=20=20Free=20the=20stack=20before=20returning.=20(Eliseo=20M?= =?UTF-8?q?art=C3=ADnez)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/regexp_nfa.c | 7 +++++++ src/version.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index e67f6380c1..825f960ca7 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -3156,6 +3156,7 @@ post2nfa(postfix, end, nfa_calc_size) if (stackp < stack) \ { \ st_error(postfix, end, p); \ + vim_free(stack); \ return NULL; \ } @@ -3632,10 +3633,16 @@ post2nfa(postfix, end, nfa_calc_size) e = POP(); if (stackp != stack) + { + vim_free(stack); EMSG_RET_NULL(_("E875: (NFA regexp) (While converting from postfix to NFA), too many states left on stack")); + } if (istate >= nstate) + { + vim_free(stack); 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; diff --git a/src/version.c b/src/version.c index 4cbf4b6ae3..21261e4d2c 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 696, /**/ 695, /**/