diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-02-04 12:39:57 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-02-11 19:10:36 +0100 |
commit | 77ace65bdce379f2d9b13ee81ab3fc01951f92dc (patch) | |
tree | 97ecd61a19769536a8be3b6b7281ce0ff40a69d0 | |
parent | d7038127ca6b356ad33fdec08aa3b23ac6a817af (diff) | |
download | rneovim-77ace65bdce379f2d9b13ee81ab3fc01951f92dc.tar.gz rneovim-77ace65bdce379f2d9b13ee81ab3fc01951f92dc.tar.bz2 rneovim-77ace65bdce379f2d9b13ee81ab3fc01951f92dc.zip |
coverity/13773: Resource leak: RI.
Problem : Resource leak @ 3324.
Diagnostic : Real issue.
Rationale : Stack is not being freed on error cases.
Resolution : Free stack before invoking EMSG_RET_NULL.
-rw-r--r-- | src/nvim/regexp_nfa.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index b082903282..99e9c3afec 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -2887,6 +2887,7 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size) if (stackp < stack) \ { \ st_error(postfix, end, p); \ + free(stack); \ return NULL; \ } @@ -3316,13 +3317,17 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size) } e = POP(); - if (stackp != stack) - EMSG_RET_NULL(_( - "E875: (NFA regexp) (While converting from postfix to NFA), too many states left on stack")); + if (stackp != stack) { + free(stack); + EMSG_RET_NULL(_("E875: (NFA regexp) (While converting from postfix to NFA)," + "too many states left on stack")); + } - if (istate >= nstate) - EMSG_RET_NULL(_( - "E876: (NFA regexp) Not enough space to store the whole NFA ")); + if (istate >= nstate) { + 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; |