]>
Commit | Line | Data |
---|---|---|
d02ad552 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.167 | |
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 6.2.167 | |
11 | Problem: The Python interface leaks memory when assigning lines to a | |
12 | buffer. (Sergey Khorev) | |
13 | Solution: Do not copy the line when calling ml_replace(). | |
14 | Files: src/if_python.c | |
15 | ||
16 | ||
17 | *** ../vim-6.2.166/src/if_python.c Wed Nov 12 20:56:23 2003 | |
18 | --- src/if_python.c Tue Dec 23 10:26:13 2003 | |
19 | *************** | |
20 | *** 2241,2256 **** | |
21 | if (save == NULL) | |
22 | return FAIL; | |
23 | ||
24 | ! /* We do not need to free save, as we pass responsibility for | |
25 | ! * it to vim, via the final parameter of ml_replace(). | |
26 | ! */ | |
27 | PyErr_Clear(); | |
28 | curbuf = buf; | |
29 | ||
30 | if (u_savesub((linenr_T)n) == FAIL) | |
31 | PyErr_SetVim(_("cannot save undo information")); | |
32 | ! else if (ml_replace((linenr_T)n, (char_u *)save, TRUE) == FAIL) | |
33 | PyErr_SetVim(_("cannot replace line")); | |
34 | else | |
35 | changed_bytes((linenr_T)n, 0); | |
36 | ||
37 | --- 2246,2265 ---- | |
38 | if (save == NULL) | |
39 | return FAIL; | |
40 | ||
41 | ! /* We do not need to free "save" if ml_replace() consumes it. */ | |
42 | PyErr_Clear(); | |
43 | curbuf = buf; | |
44 | ||
45 | if (u_savesub((linenr_T)n) == FAIL) | |
46 | + { | |
47 | PyErr_SetVim(_("cannot save undo information")); | |
48 | ! vim_free(save); | |
49 | ! } | |
50 | ! else if (ml_replace((linenr_T)n, (char_u *)save, FALSE) == FAIL) | |
51 | ! { | |
52 | PyErr_SetVim(_("cannot replace line")); | |
53 | + vim_free(save); | |
54 | + } | |
55 | else | |
56 | changed_bytes((linenr_T)n, 0); | |
57 | ||
58 | *************** | |
59 | *** 2390,2402 **** | |
60 | if (!PyErr_Occurred()) | |
61 | { | |
62 | for (i = 0; i < old_len && i < new_len; ++i) | |
63 | ! if (ml_replace((linenr_T)(lo+i), (char_u *)array[i], TRUE) | |
64 | == FAIL) | |
65 | { | |
66 | PyErr_SetVim(_("cannot replace line")); | |
67 | break; | |
68 | } | |
69 | } | |
70 | ||
71 | /* Now we may need to insert the remaining new old_len. If we do, we | |
72 | * must free the strings as we finish with them (we can't pass the | |
73 | --- 2399,2413 ---- | |
74 | if (!PyErr_Occurred()) | |
75 | { | |
76 | for (i = 0; i < old_len && i < new_len; ++i) | |
77 | ! if (ml_replace((linenr_T)(lo+i), (char_u *)array[i], FALSE) | |
78 | == FAIL) | |
79 | { | |
80 | PyErr_SetVim(_("cannot replace line")); | |
81 | break; | |
82 | } | |
83 | } | |
84 | + else | |
85 | + i = 0; | |
86 | ||
87 | /* Now we may need to insert the remaining new old_len. If we do, we | |
88 | * must free the strings as we finish with them (we can't pass the | |
89 | *** ../vim-6.2.166/src/version.c Mon Dec 29 21:04:38 2003 | |
90 | --- src/version.c Mon Dec 29 21:06:33 2003 | |
91 | *************** | |
92 | *** 639,640 **** | |
93 | --- 639,642 ---- | |
94 | { /* Add new patch number below this line */ | |
95 | + /**/ | |
96 | + 167, | |
97 | /**/ | |
98 | ||
99 | -- | |
100 | From "know your smileys": | |
101 | |-( Contact lenses, but has lost them | |
102 | ||
103 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
104 | /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ | |
105 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
106 | \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |