diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-05-09 21:44:38 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-05-10 04:01:25 +0200 |
commit | cb8ea55d7174c44ece72098eb853aacd608a0aa3 (patch) | |
tree | bdab81a1d0d73d44943a346814b7203969560165 /src | |
parent | 79a0d827550d7816c9c021fb66926b8a650f8837 (diff) | |
download | rneovim-cb8ea55d7174c44ece72098eb853aacd608a0aa3.tar.gz rneovim-cb8ea55d7174c44ece72098eb853aacd608a0aa3.tar.bz2 rneovim-cb8ea55d7174c44ece72098eb853aacd608a0aa3.zip |
nvim_eval: fix memory leak
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/vim.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 1f7f13c831..fd9cf332d5 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -290,13 +290,15 @@ Object nvim_eval(String expr, Error *err) try_start(); typval_T rettv; - if (eval0((char_u *)expr.data, &rettv, NULL, true) == FAIL) { - // This generic error should be overwritten by try_end() since #8371. - api_set_error(err, kErrorTypeException, "Failed to evaluate expression"); - } + int ok = eval0((char_u *)expr.data, &rettv, NULL, true); if (!try_end(err)) { - rv = vim_to_object(&rettv); + if (ok == FAIL) { + // Should never happen, try_end() should get the error. #8371 + api_set_error(err, kErrorTypeException, "Failed to evaluate expression"); + } else { + rv = vim_to_object(&rettv); + } } tv_clear(&rettv); |