]> git.pld-linux.org Git - packages/vim.git/blame - 7.0.183
- new
[packages/vim.git] / 7.0.183
CommitLineData
9b411fd1
ER
1To: vim-dev@vim.org
2Subject: patch 7.0.183
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=ISO-8859-1
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.0.183
11Problem: Crash in ":let" when redirecting to a variable that's being
12 displayed. (Thomas Link)
13Solution: When redirecting to a variable only do the assignment when
14 stopping redirection to avoid that setting the variable causes a
15 freed string to be accessed.
16Files: src/eval.c
17
18
19*** ../vim-7.0.182/src/eval.c Tue Dec 5 10:33:57 2006
20--- src/eval.c Sun Jan 14 14:20:49 2007
21***************
22*** 898,903 ****
23--- 898,904 ----
24 }
25
26 static lval_T *redir_lval = NULL;
27+ static garray_T redir_ga; /* only valid when redir_lval is not NULL */
28 static char_u *redir_endp = NULL;
29 static char_u *redir_varname = NULL;
30
31***************
32*** 932,937 ****
33--- 933,941 ----
34 return FAIL;
35 }
36
37+ /* The output is stored in growarray "redir_ga" until redirection ends. */
38+ ga_init2(&redir_ga, (int)sizeof(char), 500);
39+
40 /* Parse the variable name (can be a dict or list entry). */
41 redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE,
42 FNE_CHECK_START);
43***************
44*** 974,1015 ****
45 }
46
47 /*
48! * Append "value[len]" to the variable set by var_redir_start().
49 */
50 void
51! var_redir_str(value, len)
52 char_u *value;
53! int len;
54 {
55! char_u *val;
56! typval_T tv;
57! int save_emsg;
58! int err;
59
60 if (redir_lval == NULL)
61 return;
62
63! if (len == -1)
64! /* Append the entire string */
65! val = vim_strsave(value);
66! else
67! /* Append only the specified number of characters */
68! val = vim_strnsave(value, len);
69! if (val == NULL)
70! return;
71!
72! tv.v_type = VAR_STRING;
73! tv.vval.v_string = val;
74
75! save_emsg = did_emsg;
76! did_emsg = FALSE;
77! set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
78! err = did_emsg;
79! did_emsg |= save_emsg;
80! if (err)
81 var_redir_stop();
82-
83- vim_free(tv.vval.v_string);
84 }
85
86 /*
87--- 978,1013 ----
88 }
89
90 /*
91! * Append "value[value_len]" to the variable set by var_redir_start().
92! * The actual appending is postponed until redirection ends, because the value
93! * appended may in fact be the string we write to, changing it may cause freed
94! * memory to be used:
95! * :redir => foo
96! * :let foo
97! * :redir END
98 */
99 void
100! var_redir_str(value, value_len)
101 char_u *value;
102! int value_len;
103 {
104! size_t len;
105
106 if (redir_lval == NULL)
107 return;
108
109! if (value_len == -1)
110! len = STRLEN(value); /* Append the entire string */
111! else
112! len = value_len; /* Append only "value_len" characters */
113
114! if (ga_grow(&redir_ga, (int)len) == OK)
115! {
116! mch_memmove((char *)redir_ga.ga_data + redir_ga.ga_len, value, len);
117! redir_ga.ga_len += len;
118! }
119! else
120 var_redir_stop();
121 }
122
123 /*
124***************
125*** 1018,1025 ****
126--- 1016,1034 ----
127 void
128 var_redir_stop()
129 {
130+ typval_T tv;
131+
132 if (redir_lval != NULL)
133 {
134+ /* Append the trailing NUL. */
135+ ga_append(&redir_ga, NUL);
136+
137+ /* Assign the text to the variable. */
138+ tv.v_type = VAR_STRING;
139+ tv.vval.v_string = redir_ga.ga_data;
140+ set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
141+ vim_free(tv.vval.v_string);
142+
143 clear_lval(redir_lval);
144 vim_free(redir_lval);
145 redir_lval = NULL;
146*** ../vim-7.0.182/src/version.c Tue Jan 9 20:29:55 2007
147--- src/version.c Sun Jan 14 15:23:23 2007
148***************
149*** 668,669 ****
150--- 668,671 ----
151 { /* Add new patch number below this line */
152+ /**/
153+ 183,
154 /**/
155
156--
157How To Keep A Healthy Level Of Insanity:
15816. Have your coworkers address you by your wrestling name, Rock Hard Kim.
159
160 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
161/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
162\\\ download, build and distribute -- http://www.A-A-P.org ///
163 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
This page took 0.047156 seconds and 4 git commands to generate.