]>
Commit | Line | Data |
---|---|---|
c936e692 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.2.273 | |
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.273 | |
11 | Problem: Crash with redir to unknown array. (Christian Brabandt) | |
12 | Solution: Don't assign the redir result when there was an error. | |
13 | Files: src/eval.c | |
14 | ||
15 | ||
16 | *** ../vim-7.2.272/src/eval.c 2009-09-30 15:15:33.000000000 +0200 | |
17 | --- src/eval.c 2009-11-03 12:05:07.000000000 +0100 | |
18 | *************** | |
19 | *** 988,1000 **** | |
20 | int err; | |
21 | typval_T tv; | |
22 | ||
23 | ! /* Make sure a valid variable name is specified */ | |
24 | if (!eval_isnamec1(*name)) | |
25 | { | |
26 | EMSG(_(e_invarg)); | |
27 | return FAIL; | |
28 | } | |
29 | ||
30 | redir_varname = vim_strsave(name); | |
31 | if (redir_varname == NULL) | |
32 | return FAIL; | |
33 | --- 988,1001 ---- | |
34 | int err; | |
35 | typval_T tv; | |
36 | ||
37 | ! /* Catch a bad name early. */ | |
38 | if (!eval_isnamec1(*name)) | |
39 | { | |
40 | EMSG(_(e_invarg)); | |
41 | return FAIL; | |
42 | } | |
43 | ||
44 | + /* Make a copy of the name, it is used in redir_lval until redir ends. */ | |
45 | redir_varname = vim_strsave(name); | |
46 | if (redir_varname == NULL) | |
47 | return FAIL; | |
48 | *************** | |
49 | *** 1019,1024 **** | |
50 | --- 1020,1026 ---- | |
51 | EMSG(_(e_trailing)); | |
52 | else | |
53 | EMSG(_(e_invarg)); | |
54 | + redir_endp = NULL; /* don't store a value, only cleanup */ | |
55 | var_redir_stop(); | |
56 | return FAIL; | |
57 | } | |
58 | *************** | |
59 | *** 1037,1042 **** | |
60 | --- 1039,1045 ---- | |
61 | did_emsg |= save_emsg; | |
62 | if (err) | |
63 | { | |
64 | + redir_endp = NULL; /* don't store a value, only cleanup */ | |
65 | var_redir_stop(); | |
66 | return FAIL; | |
67 | } | |
68 | *************** | |
69 | *** 1085,1090 **** | |
70 | --- 1088,1094 ---- | |
71 | ||
72 | /* | |
73 | * Stop redirecting command output to a variable. | |
74 | + * Frees the allocated memory. | |
75 | */ | |
76 | void | |
77 | var_redir_stop() | |
78 | *************** | |
79 | *** 1093,1106 **** | |
80 | ||
81 | if (redir_lval != NULL) | |
82 | { | |
83 | ! /* Append the trailing NUL. */ | |
84 | ! ga_append(&redir_ga, NUL); | |
85 | ||
86 | ! /* Assign the text to the variable. */ | |
87 | ! tv.v_type = VAR_STRING; | |
88 | ! tv.vval.v_string = redir_ga.ga_data; | |
89 | ! set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)"."); | |
90 | ! vim_free(tv.vval.v_string); | |
91 | ||
92 | clear_lval(redir_lval); | |
93 | vim_free(redir_lval); | |
94 | --- 1097,1114 ---- | |
95 | ||
96 | if (redir_lval != NULL) | |
97 | { | |
98 | ! /* If there was no error: assign the text to the variable. */ | |
99 | ! if (redir_endp != NULL) | |
100 | ! { | |
101 | ! ga_append(&redir_ga, NUL); /* Append the trailing NUL. */ | |
102 | ! tv.v_type = VAR_STRING; | |
103 | ! tv.vval.v_string = redir_ga.ga_data; | |
104 | ! set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)"."); | |
105 | ! } | |
106 | ||
107 | ! /* free the collected output */ | |
108 | ! vim_free(redir_ga.ga_data); | |
109 | ! redir_ga.ga_data = NULL; | |
110 | ||
111 | clear_lval(redir_lval); | |
112 | vim_free(redir_lval); | |
113 | *** ../vim-7.2.272/src/version.c 2009-11-03 13:06:03.000000000 +0100 | |
114 | --- src/version.c 2009-11-03 14:24:06.000000000 +0100 | |
115 | *************** | |
116 | *** 678,679 **** | |
117 | --- 678,681 ---- | |
118 | { /* Add new patch number below this line */ | |
119 | + /**/ | |
120 | + 273, | |
121 | /**/ | |
122 | ||
123 | -- | |
124 | Permission is granted to read this message out aloud on Kings Cross Road, | |
125 | London, under the condition that the orator is properly dressed. | |
126 | ||
127 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
128 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
129 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
130 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |