]> git.pld-linux.org Git - packages/vim.git/blob - 7.2.347
- new
[packages/vim.git] / 7.2.347
1 To: vim-dev@vim.org
2 Subject: Patch 7.2.347
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.2.347
11 Problem:    Crash when executing <expr> mapping redefines that same mapping.
12 Solution:   Save the values used before evaluating the expression.
13 Files:      src/getchar.c
14
15
16 *** ../vim-7.2.346/src/getchar.c        2009-11-11 16:23:37.000000000 +0100
17 --- src/getchar.c       2010-01-27 17:30:42.000000000 +0100
18 ***************
19 *** 2389,2394 ****
20 --- 2389,2405 ----
21                     /* complete match */
22                     if (keylen >= 0 && keylen <= typebuf.tb_len)
23                     {
24 + #ifdef FEAT_EVAL
25 +                       int save_m_expr;
26 +                       int save_m_noremap;
27 +                       int save_m_silent;
28 +                       char_u *save_m_keys;
29 +                       char_u *save_m_str;
30 + #else
31 + # define save_m_noremap mp->m_noremap
32 + # define save_m_silent mp->m_silent
33 + #endif
34
35                         /* write chars to script file(s) */
36                         if (keylen > typebuf.tb_maplen)
37                             gotchars(typebuf.tb_buf + typebuf.tb_off
38 ***************
39 *** 2431,2436 ****
40 --- 2442,2457 ----
41   #endif
42   
43   #ifdef FEAT_EVAL
44 +                       /* Copy the values from *mp that are used, because
45 +                        * evaluating the expression may invoke a function
46 +                        * that redefines the mapping, thereby making *mp
47 +                        * invalid. */
48 +                       save_m_expr = mp->m_expr;
49 +                       save_m_noremap = mp->m_noremap;
50 +                       save_m_silent = mp->m_silent;
51 +                       save_m_keys = NULL;  /* only saved when needed */
52 +                       save_m_str = NULL;  /* only saved when needed */
53
54                         /*
55                          * Handle ":map <expr>": evaluate the {rhs} as an
56                          * expression.  Save and restore the typeahead so that
57 ***************
58 *** 2446,2452 ****
59                             if (tabuf.typebuf_valid)
60                             {
61                                 vgetc_busy = 0;
62 !                               s = eval_map_expr(mp->m_str, NUL);
63                                 vgetc_busy = save_vgetc_busy;
64                             }
65                             else
66 --- 2467,2475 ----
67                             if (tabuf.typebuf_valid)
68                             {
69                                 vgetc_busy = 0;
70 !                               save_m_keys = vim_strsave(mp->m_keys);
71 !                               save_m_str = vim_strsave(mp->m_str);
72 !                               s = eval_map_expr(save_m_str, NUL);
73                                 vgetc_busy = save_vgetc_busy;
74                             }
75                             else
76 ***************
77 *** 2470,2486 ****
78                         else
79                         {
80                             i = ins_typebuf(s,
81 !                                   mp->m_noremap != REMAP_YES
82 !                                           ? mp->m_noremap
83 !                                           : STRNCMP(s, mp->m_keys,
84                                                           (size_t)keylen) != 0
85                                                      ? REMAP_YES : REMAP_SKIP,
86 !                               0, TRUE, cmd_silent || mp->m_silent);
87   #ifdef FEAT_EVAL
88 !                           if (mp->m_expr)
89                                 vim_free(s);
90   #endif
91                         }
92                         if (i == FAIL)
93                         {
94                             c = -1;
95 --- 2493,2517 ----
96                         else
97                         {
98                             i = ins_typebuf(s,
99 !                                   save_m_noremap != REMAP_YES
100 !                                           ? save_m_noremap
101 !                                           : STRNCMP(s,
102 ! #ifdef FEAT_EVAL
103 !                                          save_m_keys != NULL ? save_m_keys :
104 ! #endif
105 !                                                     mp->m_keys,
106                                                           (size_t)keylen) != 0
107                                                      ? REMAP_YES : REMAP_SKIP,
108 !                               0, TRUE, cmd_silent || save_m_silent);
109   #ifdef FEAT_EVAL
110 !                           if (save_m_expr)
111                                 vim_free(s);
112   #endif
113                         }
114 + #ifdef FEAT_EVAL
115 +                       vim_free(save_m_keys);
116 +                       vim_free(save_m_str);
117 + #endif
118                         if (i == FAIL)
119                         {
120                             c = -1;
121 *** ../vim-7.2.346/src/version.c        2010-01-27 16:31:00.000000000 +0100
122 --- src/version.c       2010-01-27 17:27:32.000000000 +0100
123 ***************
124 *** 683,684 ****
125 --- 683,686 ----
126   {   /* Add new patch number below this line */
127 + /**/
128 +     347,
129   /**/
130
131 -- 
132 hundred-and-one symptoms of being an internet addict:
133 156. You forget your friend's name but not her e-mail address.
134
135  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
136 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
137 \\\        download, build and distribute -- http://www.A-A-P.org        ///
138  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.042373 seconds and 3 git commands to generate.