summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.2.347
diff options
context:
space:
mode:
Diffstat (limited to 'source/ap/vim/patches/7.2.347')
-rw-r--r--source/ap/vim/patches/7.2.347138
1 files changed, 138 insertions, 0 deletions
diff --git a/source/ap/vim/patches/7.2.347 b/source/ap/vim/patches/7.2.347
new file mode 100644
index 00000000..e5fa17d4
--- /dev/null
+++ b/source/ap/vim/patches/7.2.347
@@ -0,0 +1,138 @@
+To: vim-dev@vim.org
+Subject: Patch 7.2.347
+Fcc: outbox
+From: Bram Moolenaar <Bram@moolenaar.net>
+Mime-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+------------
+
+Patch 7.2.347
+Problem: Crash when executing <expr> mapping redefines that same mapping.
+Solution: Save the values used before evaluating the expression.
+Files: src/getchar.c
+
+
+*** ../vim-7.2.346/src/getchar.c 2009-11-11 16:23:37.000000000 +0100
+--- src/getchar.c 2010-01-27 17:30:42.000000000 +0100
+***************
+*** 2389,2394 ****
+--- 2389,2405 ----
+ /* complete match */
+ if (keylen >= 0 && keylen <= typebuf.tb_len)
+ {
++ #ifdef FEAT_EVAL
++ int save_m_expr;
++ int save_m_noremap;
++ int save_m_silent;
++ char_u *save_m_keys;
++ char_u *save_m_str;
++ #else
++ # define save_m_noremap mp->m_noremap
++ # define save_m_silent mp->m_silent
++ #endif
++
+ /* write chars to script file(s) */
+ if (keylen > typebuf.tb_maplen)
+ gotchars(typebuf.tb_buf + typebuf.tb_off
+***************
+*** 2431,2436 ****
+--- 2442,2457 ----
+ #endif
+
+ #ifdef FEAT_EVAL
++ /* Copy the values from *mp that are used, because
++ * evaluating the expression may invoke a function
++ * that redefines the mapping, thereby making *mp
++ * invalid. */
++ save_m_expr = mp->m_expr;
++ save_m_noremap = mp->m_noremap;
++ save_m_silent = mp->m_silent;
++ save_m_keys = NULL; /* only saved when needed */
++ save_m_str = NULL; /* only saved when needed */
++
+ /*
+ * Handle ":map <expr>": evaluate the {rhs} as an
+ * expression. Save and restore the typeahead so that
+***************
+*** 2446,2452 ****
+ if (tabuf.typebuf_valid)
+ {
+ vgetc_busy = 0;
+! s = eval_map_expr(mp->m_str, NUL);
+ vgetc_busy = save_vgetc_busy;
+ }
+ else
+--- 2467,2475 ----
+ if (tabuf.typebuf_valid)
+ {
+ vgetc_busy = 0;
+! save_m_keys = vim_strsave(mp->m_keys);
+! save_m_str = vim_strsave(mp->m_str);
+! s = eval_map_expr(save_m_str, NUL);
+ vgetc_busy = save_vgetc_busy;
+ }
+ else
+***************
+*** 2470,2486 ****
+ else
+ {
+ i = ins_typebuf(s,
+! mp->m_noremap != REMAP_YES
+! ? mp->m_noremap
+! : STRNCMP(s, mp->m_keys,
+ (size_t)keylen) != 0
+ ? REMAP_YES : REMAP_SKIP,
+! 0, TRUE, cmd_silent || mp->m_silent);
+ #ifdef FEAT_EVAL
+! if (mp->m_expr)
+ vim_free(s);
+ #endif
+ }
+ if (i == FAIL)
+ {
+ c = -1;
+--- 2493,2517 ----
+ else
+ {
+ i = ins_typebuf(s,
+! save_m_noremap != REMAP_YES
+! ? save_m_noremap
+! : STRNCMP(s,
+! #ifdef FEAT_EVAL
+! save_m_keys != NULL ? save_m_keys :
+! #endif
+! mp->m_keys,
+ (size_t)keylen) != 0
+ ? REMAP_YES : REMAP_SKIP,
+! 0, TRUE, cmd_silent || save_m_silent);
+ #ifdef FEAT_EVAL
+! if (save_m_expr)
+ vim_free(s);
+ #endif
+ }
++ #ifdef FEAT_EVAL
++ vim_free(save_m_keys);
++ vim_free(save_m_str);
++ #endif
+ if (i == FAIL)
+ {
+ c = -1;
+*** ../vim-7.2.346/src/version.c 2010-01-27 16:31:00.000000000 +0100
+--- src/version.c 2010-01-27 17:27:32.000000000 +0100
+***************
+*** 683,684 ****
+--- 683,686 ----
+ { /* Add new patch number below this line */
++ /**/
++ 347,
+ /**/
+
+--
+hundred-and-one symptoms of being an internet addict:
+156. You forget your friend's name but not her e-mail address.
+
+ /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
+/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
+\\\ download, build and distribute -- http://www.A-A-P.org ///
+ \\\ help me help AIDS victims -- http://ICCF-Holland.org ///