]>
Commit | Line | Data |
---|---|---|
2f43f8e6 ER |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.2.036 (extra) | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.2.036 (extra) | |
11 | Problem: Mismatches between alloc/malloc, free/vim_free, | |
12 | realloc/vim_realloc. | |
13 | Solution: Use the right function. (Dominique Pelle) | |
14 | Files: src/gui_riscos.c, src/gui_w48.c, src/mbyte.c, src/os_vms.c, | |
15 | src/os_w32exe.c, src/os_win16.c | |
16 | ||
17 | ||
18 | *** ../vim-7.2.035/src/gui_riscos.c Thu May 10 19:33:26 2007 | |
19 | --- src/gui_riscos.c Wed Nov 12 11:47:54 2008 | |
20 | *************** | |
21 | *** 695,701 **** | |
22 | gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction) | |
23 | int width; /* In OS units */ | |
24 | int height; | |
25 | ! int min_width; /* Smallest permissable window size (ignored) */ | |
26 | int min_height; | |
27 | int base_width; /* Space for scroll bars, etc */ | |
28 | int base_height; | |
29 | --- 695,701 ---- | |
30 | gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction) | |
31 | int width; /* In OS units */ | |
32 | int height; | |
33 | ! int min_width; /* Smallest permissible window size (ignored) */ | |
34 | int min_height; | |
35 | int base_width; /* Space for scroll bars, etc */ | |
36 | int base_height; | |
37 | *************** | |
38 | *** 863,869 **** | |
39 | if (strncmp(file, "ZapFont\015", 8) == 0) | |
40 | return file; /* Loaded OK! */ | |
41 | ||
42 | ! free(file); | |
43 | return NULL; /* Not a valid font file */ | |
44 | } | |
45 | ||
46 | --- 863,869 ---- | |
47 | if (strncmp(file, "ZapFont\015", 8) == 0) | |
48 | return file; /* Loaded OK! */ | |
49 | ||
50 | ! vim_free(file); | |
51 | return NULL; /* Not a valid font file */ | |
52 | } | |
53 | ||
54 | *** ../vim-7.2.035/src/gui_w48.c Thu Jul 24 20:50:23 2008 | |
55 | --- src/gui_w48.c Wed Nov 12 11:37:41 2008 | |
56 | *************** | |
57 | *** 3335,3341 **** | |
58 | ||
59 | /* | |
60 | * Convert the string s to the proper format for a filter string by replacing | |
61 | ! * the \t and \n delimeters with \0. | |
62 | * Returns the converted string in allocated memory. | |
63 | * | |
64 | * Keep in sync with convert_filterW() above! | |
65 | --- 3335,3341 ---- | |
66 | ||
67 | /* | |
68 | * Convert the string s to the proper format for a filter string by replacing | |
69 | ! * the \t and \n delimiters with \0. | |
70 | * Returns the converted string in allocated memory. | |
71 | * | |
72 | * Keep in sync with convert_filterW() above! | |
73 | *************** | |
74 | *** 3674,3680 **** | |
75 | * Use "prog" as the name of the program and "cmdline" as the arguments. | |
76 | * Copy the arguments to allocated memory. | |
77 | * Return the number of arguments (including program name). | |
78 | ! * Return pointers to the arguments in "argvp". | |
79 | * Return pointer to buffer in "tofree". | |
80 | * Returns zero when out of memory. | |
81 | */ | |
82 | --- 3674,3681 ---- | |
83 | * Use "prog" as the name of the program and "cmdline" as the arguments. | |
84 | * Copy the arguments to allocated memory. | |
85 | * Return the number of arguments (including program name). | |
86 | ! * Return pointers to the arguments in "argvp". Memory is allocated with | |
87 | ! * malloc(), use free() instead of vim_free(). | |
88 | * Return pointer to buffer in "tofree". | |
89 | * Returns zero when out of memory. | |
90 | */ | |
91 | *************** | |
92 | *** 3692,3697 **** | |
93 | --- 3693,3700 ---- | |
94 | char **argv = NULL; | |
95 | int round; | |
96 | ||
97 | + *tofree = NULL; | |
98 | + | |
99 | #ifdef FEAT_MBYTE | |
100 | /* Try using the Unicode version first, it takes care of conversion when | |
101 | * 'encoding' is changed. */ | |
102 | *************** | |
103 | *** 3802,3816 **** | |
104 | argv = (char **)malloc((argc + 1) * sizeof(char *)); | |
105 | if (argv == NULL ) | |
106 | { | |
107 | ! vim_free(newcmdline); | |
108 | return 0; /* malloc error */ | |
109 | } | |
110 | pnew = newcmdline; | |
111 | } | |
112 | } | |
113 | ||
114 | done: | |
115 | - | |
116 | argv[argc] = NULL; /* NULL-terminated list */ | |
117 | *argvp = argv; | |
118 | return argc; | |
119 | --- 3805,3819 ---- | |
120 | argv = (char **)malloc((argc + 1) * sizeof(char *)); | |
121 | if (argv == NULL ) | |
122 | { | |
123 | ! free(newcmdline); | |
124 | return 0; /* malloc error */ | |
125 | } | |
126 | pnew = newcmdline; | |
127 | + *tofree = newcmdline; | |
128 | } | |
129 | } | |
130 | ||
131 | done: | |
132 | argv[argc] = NULL; /* NULL-terminated list */ | |
133 | *argvp = argv; | |
134 | return argc; | |
135 | *** ../vim-7.2.035/src/os_vms.c Wed Aug 6 18:38:52 2008 | |
136 | --- src/os_vms.c Wed Nov 12 11:42:12 2008 | |
137 | *************** | |
138 | *** 228,234 **** | |
139 | else if ((sbuf = getenv((char *)lognam))) | |
140 | { | |
141 | lengte = strlen(sbuf) + 1; | |
142 | ! cp = (char_u *)malloc((size_t)lengte); | |
143 | if (cp) | |
144 | strcpy((char *)cp, sbuf); | |
145 | return cp; | |
146 | --- 228,234 ---- | |
147 | else if ((sbuf = getenv((char *)lognam))) | |
148 | { | |
149 | lengte = strlen(sbuf) + 1; | |
150 | ! cp = (char_u *)alloc((size_t)lengte); | |
151 | if (cp) | |
152 | strcpy((char *)cp, sbuf); | |
153 | return cp; | |
154 | *************** | |
155 | *** 381,387 **** | |
156 | if (--vms_match_free == 0) { | |
157 | /* add more space to store matches */ | |
158 | vms_match_alloced += EXPL_ALLOC_INC; | |
159 | ! vms_fmatch = (char_u **)realloc(vms_fmatch, | |
160 | sizeof(char **) * vms_match_alloced); | |
161 | if (!vms_fmatch) | |
162 | return 0; | |
163 | --- 381,387 ---- | |
164 | if (--vms_match_free == 0) { | |
165 | /* add more space to store matches */ | |
166 | vms_match_alloced += EXPL_ALLOC_INC; | |
167 | ! vms_fmatch = (char_u **)vim_realloc(vms_fmatch, | |
168 | sizeof(char **) * vms_match_alloced); | |
169 | if (!vms_fmatch) | |
170 | return 0; | |
171 | *************** | |
172 | *** 460,466 **** | |
173 | if (--files_free < 1) | |
174 | { | |
175 | files_alloced += EXPL_ALLOC_INC; | |
176 | ! *file = (char_u **)realloc(*file, | |
177 | sizeof(char_u **) * files_alloced); | |
178 | if (*file == NULL) | |
179 | { | |
180 | --- 460,466 ---- | |
181 | if (--files_free < 1) | |
182 | { | |
183 | files_alloced += EXPL_ALLOC_INC; | |
184 | ! *file = (char_u **)vim_realloc(*file, | |
185 | sizeof(char_u **) * files_alloced); | |
186 | if (*file == NULL) | |
187 | { | |
188 | *************** | |
189 | *** 614,627 **** | |
190 | { | |
191 | buflen = len + 128; | |
192 | if (buf) | |
193 | ! buf = (char *)realloc(buf, buflen); | |
194 | else | |
195 | ! buf = (char *)calloc(buflen, sizeof(char)); | |
196 | } | |
197 | ||
198 | #ifdef DEBUG | |
199 | char *tmpbuf = NULL; | |
200 | ! tmpbuf = (char *)calloc(buflen, sizeof(char)); | |
201 | strcpy(tmpbuf, instring); | |
202 | #endif | |
203 | ||
204 | --- 614,627 ---- | |
205 | { | |
206 | buflen = len + 128; | |
207 | if (buf) | |
208 | ! buf = (char *)vim_realloc(buf, buflen); | |
209 | else | |
210 | ! buf = (char *)alloc(buflen * sizeof(char)); | |
211 | } | |
212 | ||
213 | #ifdef DEBUG | |
214 | char *tmpbuf = NULL; | |
215 | ! tmpbuf = (char *)alloc(buflen * sizeof(char)); | |
216 | strcpy(tmpbuf, instring); | |
217 | #endif | |
218 | ||
219 | *** ../vim-7.2.035/src/os_w32exe.c Fri Jul 1 00:06:20 2005 | |
220 | --- src/os_w32exe.c Wed Nov 12 11:45:43 2008 | |
221 | *************** | |
222 | *** 129,135 **** | |
223 | errout: | |
224 | #endif | |
225 | free(argv); | |
226 | ! free(tofree); | |
227 | #ifdef FEAT_MBYTE | |
228 | free_cmd_argsW(); | |
229 | #endif | |
230 | --- 129,136 ---- | |
231 | errout: | |
232 | #endif | |
233 | free(argv); | |
234 | ! if (tofree != NULL) | |
235 | ! free(tofree); | |
236 | #ifdef FEAT_MBYTE | |
237 | free_cmd_argsW(); | |
238 | #endif | |
239 | *** ../vim-7.2.035/src/os_win16.c Wed Jun 25 00:49:34 2008 | |
240 | --- src/os_win16.c Wed Nov 12 11:45:53 2008 | |
241 | *************** | |
242 | *** 121,127 **** | |
243 | pmain(argc, argv); | |
244 | ||
245 | free(argv); | |
246 | ! free(tofree); | |
247 | ||
248 | return 0; | |
249 | } | |
250 | --- 121,128 ---- | |
251 | pmain(argc, argv); | |
252 | ||
253 | free(argv); | |
254 | ! if (tofree != NULL) | |
255 | ! free(tofree); | |
256 | ||
257 | return 0; | |
258 | } | |
259 | *** ../vim-7.2.035/src/version.c Wed Nov 12 13:07:48 2008 | |
260 | --- src/version.c Wed Nov 12 13:28:51 2008 | |
261 | *************** | |
262 | *** 678,679 **** | |
263 | --- 678,681 ---- | |
264 | { /* Add new patch number below this line */ | |
265 | + /**/ | |
266 | + 36, | |
267 | /**/ | |
268 | ||
269 | -- | |
270 | hundred-and-one symptoms of being an internet addict: | |
271 | 239. You think "surfing" is something you do on dry land. | |
272 | ||
273 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
274 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
275 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
276 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |