diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-08 22:55:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-08 22:55:26 +0200 |
commit | 8e9be208ea58149c4e522166a6194da18a2eced7 (patch) | |
tree | 7892f3d7a6dd6f1dc08bf7a108e2b44ad5e5236d | |
parent | c3516f7e4507c77424b94cb89071f6d0841f4e6a (diff) | |
download | vim-git-8e9be208ea58149c4e522166a6194da18a2eced7.tar.gz |
patch 8.2.1638: leaking memory when popup filter function can't be calledv8.2.1638
Problem: Leaking memory when popup filter function can't be called.
Solution: Don't return too soon.
-rw-r--r-- | src/popupwin.c | 44 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 25 insertions, 21 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index 23f8efc8e..d29986db5 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -3155,31 +3155,33 @@ invoke_popup_filter(win_T *wp, int c) if (call_callback(&wp->w_filter_cb, -1, &rettv, 2, argv) == FAIL) { // Cannot call the function, close the popup to avoid that the filter - // eats keys and the user can't get out. + // eats keys and the user is stuck. Might as well eat the key. popup_close_with_retval(wp, -1); - return 1; - } - - if (win_valid_popup(wp) && old_lnum != wp->w_cursor.lnum) - popup_highlight_curline(wp); - - // If an error was given always return FALSE, so that keys are not - // consumed and the user can type something. - // If we get three errors in a row then close the popup. Decrement the - // error count by 1/10 if there are no errors, thus allowing up to 1 in - // 10 calls to cause an error. - if (win_valid_popup(wp) && called_emsg > prev_called_emsg) - { - wp->w_filter_errors += 10; - if (wp->w_filter_errors >= 30) - popup_close_with_retval(wp, -1); - res = FALSE; + res = TRUE; } else { - if (win_valid_popup(wp) && wp->w_filter_errors > 0) - --wp->w_filter_errors; - res = tv_get_bool(&rettv); + if (win_valid_popup(wp) && old_lnum != wp->w_cursor.lnum) + popup_highlight_curline(wp); + + // If an error was given always return FALSE, so that keys are not + // consumed and the user can type something. + // If we get three errors in a row then close the popup. Decrement the + // error count by 1/10 if there are no errors, thus allowing up to 1 in + // 10 calls to cause an error. + if (win_valid_popup(wp) && called_emsg > prev_called_emsg) + { + wp->w_filter_errors += 10; + if (wp->w_filter_errors >= 30) + popup_close_with_retval(wp, -1); + res = FALSE; + } + else + { + if (win_valid_popup(wp) && wp->w_filter_errors > 0) + --wp->w_filter_errors; + res = tv_get_bool(&rettv); + } } vim_free(argv[1].vval.v_string); diff --git a/src/version.c b/src/version.c index bad23c572..b9207f573 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1638, +/**/ 1637, /**/ 1636, |