diff options
author | ZyX <kp-pav@yandex.ru> | 2017-07-16 22:03:31 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-07-16 22:03:31 +0300 |
commit | 2a6423eba732b005e277bac393f2246308dcc378 (patch) | |
tree | 22862021e1ef3babf996b8493b235aa2f12f0f65 /src/nvim/api/private/helpers.c | |
parent | 3660535f0229afc4ce3391d94794253f685ec400 (diff) | |
download | rneovim-2a6423eba732b005e277bac393f2246308dcc378.tar.gz rneovim-2a6423eba732b005e277bac393f2246308dcc378.tar.bz2 rneovim-2a6423eba732b005e277bac393f2246308dcc378.zip |
api helpers: Save/restore more values in try_enter/try_leave
This fixes memory leak reported by ASAN. This also somehow fixes test40, though
I have no idea why except that that test yields memory leak report.
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index a04cc9a312..6ff56709cd 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -49,13 +49,17 @@ void try_enter(TryState *const tstate) .trylevel = trylevel, .got_int = got_int, .did_throw = did_throw, + .need_rethrow = need_rethrow, + .current_exception = current_exception, .msg_list = (const struct msglist *const *)msg_list, .private_msg_list = NULL, }; trylevel = 1; got_int = false; did_throw = false; + need_rethrow = false; msg_list = &tstate->private_msg_list; + current_exception = NULL; } /// End try block, set the error message if any and restore previous state @@ -72,14 +76,17 @@ bool try_leave(const TryState *const tstate, Error *const err) { const bool ret = !try_end(err); assert(trylevel == 0); + assert(!need_rethrow); assert(!got_int); assert(!did_throw); assert(msg_list == &tstate->private_msg_list); assert(*msg_list == NULL); + assert(current_exception == NULL); trylevel = tstate->trylevel; got_int = tstate->got_int; did_throw = tstate->did_throw; msg_list = (struct msglist **)tstate->msg_list; + current_exception = tstate->current_exception; return ret; } @@ -96,6 +103,8 @@ void try_start(void) /// @return true if an error occurred bool try_end(Error *err) { + // Note: all globals manipulated here should be saved/restored in + // try_enter/try_leave. --trylevel; // Without this it stops processing all subsequent VimL commands and |