Mercurial > vim
comparison src/main.c @ 14927:162d79d273e6 v8.1.0475
patch 8.1.0475: memory not freed on exit when quit in autocmd
commit https://github.com/vim/vim/commit/27e80c885bcb5c5cf6a6462d71d6c81b06ba2451
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 14 21:41:01 2018 +0200
patch 8.1.0475: memory not freed on exit when quit in autocmd
Problem: Memory not freed on exit when quit in autocmd.
Solution: Remember funccal stack when executing autocmd.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Oct 2018 21:45:04 +0200 |
parents | 27b9a84395b5 |
children | 67e3103d6e18 |
comparison
equal
deleted
inserted
replaced
14926:f60f8f21f76f | 14927:162d79d273e6 |
---|---|
1715 } | 1715 } |
1716 return def; | 1716 return def; |
1717 } | 1717 } |
1718 | 1718 |
1719 /* | 1719 /* |
1720 * Check for: [r][e][g][vi|vim|view][diff][ex[im]] | 1720 * Check for: [r][e][g][vi|vim|view][diff][ex[im]] (sort of) |
1721 * If the executable name starts with "r" we disable shell commands. | 1721 * If the executable name starts with "r" we disable shell commands. |
1722 * If the next character is "e" we run in Easy mode. | 1722 * If the next character is "e" we run in Easy mode. |
1723 * If the next character is "g" we run the GUI version. | 1723 * If the next character is "g" we run the GUI version. |
1724 * If the next characters are "view" we start in readonly mode. | 1724 * If the next characters are "view" we start in readonly mode. |
1725 * If the next characters are "diff" or "vimdiff" we start in diff mode. | 1725 * If the next characters are "diff" or "vimdiff" we start in diff mode. |
1786 initstr += 4; | 1786 initstr += 4; |
1787 } | 1787 } |
1788 else if (STRNICMP(initstr, "vim", 3) == 0) | 1788 else if (STRNICMP(initstr, "vim", 3) == 0) |
1789 initstr += 3; | 1789 initstr += 3; |
1790 | 1790 |
1791 /* Catch "[r][g]vimdiff" and "[r][g]viewdiff". */ | 1791 // Catch "[r][g]vimdiff" and "[r][g]viewdiff". |
1792 if (STRICMP(initstr, "diff") == 0) | 1792 if (STRICMP(initstr, "diff") == 0) |
1793 { | 1793 { |
1794 #ifdef FEAT_DIFF | 1794 #ifdef FEAT_DIFF |
1795 parmp->diff_mode = TRUE; | 1795 parmp->diff_mode = TRUE; |
1796 #else | 1796 #else |
1798 mch_errmsg("\n"); | 1798 mch_errmsg("\n"); |
1799 mch_exit(2); | 1799 mch_exit(2); |
1800 #endif | 1800 #endif |
1801 } | 1801 } |
1802 | 1802 |
1803 // Checking for "ex" here may catch some weir names, such as "vimex" or | |
1804 // "viewex", we assume the user knows that. | |
1803 if (STRNICMP(initstr, "ex", 2) == 0) | 1805 if (STRNICMP(initstr, "ex", 2) == 0) |
1804 { | 1806 { |
1805 if (STRNICMP(initstr + 2, "im", 2) == 0) | 1807 if (STRNICMP(initstr + 2, "im", 2) == 0) |
1806 exmode_active = EXMODE_VIM; | 1808 exmode_active = EXMODE_VIM; |
1807 else | 1809 else |
1808 exmode_active = EXMODE_NORMAL; | 1810 exmode_active = EXMODE_NORMAL; |
1809 change_compatible(TRUE); /* set 'compatible' */ | 1811 change_compatible(TRUE); // set 'compatible' |
1810 } | 1812 } |
1811 } | 1813 } |
1812 | 1814 |
1813 /* | 1815 /* |
1814 * Scan the command line arguments. | 1816 * Scan the command line arguments. |
4186 eval_client_expr_to_string(char_u *expr) | 4188 eval_client_expr_to_string(char_u *expr) |
4187 { | 4189 { |
4188 char_u *res; | 4190 char_u *res; |
4189 int save_dbl = debug_break_level; | 4191 int save_dbl = debug_break_level; |
4190 int save_ro = redir_off; | 4192 int save_ro = redir_off; |
4191 void *fc = NULL; | 4193 funccal_entry_T funccal_entry; |
4194 int did_save_funccal = FALSE; | |
4192 | 4195 |
4193 /* Evaluate the expression at the toplevel, don't use variables local to | 4196 /* Evaluate the expression at the toplevel, don't use variables local to |
4194 * the calling function. Except when in debug mode. */ | 4197 * the calling function. Except when in debug mode. */ |
4195 if (!debug_mode) | 4198 if (!debug_mode) |
4196 fc = clear_current_funccal(); | 4199 { |
4200 save_funccal(&funccal_entry); | |
4201 did_save_funccal = TRUE; | |
4202 } | |
4197 | 4203 |
4198 /* Disable debugging, otherwise Vim hangs, waiting for "cont" to be | 4204 /* Disable debugging, otherwise Vim hangs, waiting for "cont" to be |
4199 * typed. */ | 4205 * typed. */ |
4200 debug_break_level = -1; | 4206 debug_break_level = -1; |
4201 redir_off = 0; | 4207 redir_off = 0; |
4208 debug_break_level = save_dbl; | 4214 debug_break_level = save_dbl; |
4209 redir_off = save_ro; | 4215 redir_off = save_ro; |
4210 --emsg_silent; | 4216 --emsg_silent; |
4211 if (emsg_silent < 0) | 4217 if (emsg_silent < 0) |
4212 emsg_silent = 0; | 4218 emsg_silent = 0; |
4213 if (fc != NULL) | 4219 if (did_save_funccal) |
4214 restore_current_funccal(fc); | 4220 restore_funccal(); |
4215 | 4221 |
4216 /* A client can tell us to redraw, but not to display the cursor, so do | 4222 /* A client can tell us to redraw, but not to display the cursor, so do |
4217 * that here. */ | 4223 * that here. */ |
4218 setcursor(); | 4224 setcursor(); |
4219 out_flush_cursor(FALSE, FALSE); | 4225 out_flush_cursor(FALSE, FALSE); |