4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Leaking memory when setting term to "builtin_dumb".
12 Solution: Free memory when resetting term option t_Co.
13 Files: src/option.c, src/proto/option.pro, src/term.c
16 *** ../vim-7.2.237/src/option.c 2009-06-16 17:50:56.000000000 +0200
17 --- src/option.c 2009-07-22 12:49:19.000000000 +0200
20 #define P_NUM 0x02 /* the option is numeric */
21 #define P_STRING 0x04 /* the option is a string */
22 #define P_ALLOCED 0x08 /* the string option is in allocated memory,
23 ! must use vim_free() when assigning new
24 ! value. Not set if default is the same. */
25 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
26 never be used for local or hidden options! */
27 #define P_NODEFAULT 0x40 /* don't set to default value */
29 #define P_NUM 0x02 /* the option is numeric */
30 #define P_STRING 0x04 /* the option is a string */
31 #define P_ALLOCED 0x08 /* the string option is in allocated memory,
32 ! must use free_string_option() when
33 ! assigning new value. Not set if default is
35 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
36 never be used for local or hidden options! */
37 #define P_NODEFAULT 0x40 /* don't set to default value */
44 + * Free the string for one term option, if it was allocated.
45 + * Set the string to empty_option and clear allocated flag.
46 + * "var" points to the option value.
49 + free_one_termoption(var)
52 + struct vimoption *p;
54 + for (p = &options[0]; p->fullname != NULL; p++)
57 + if (p->flags & P_ALLOCED)
58 + free_string_option(*(char_u **)(p->var));
59 + *(char_u **)(p->var) = empty_option;
60 + p->flags &= ~P_ALLOCED;
66 * Set the terminal option defaults to the current value.
67 * Used after setting the terminal name.
69 *** ../vim-7.2.237/src/proto/option.pro 2009-02-21 20:27:00.000000000 +0100
70 --- src/proto/option.pro 2009-07-22 12:52:31.000000000 +0200
74 int makefoldset __ARGS((FILE *fd));
75 void clear_termoptions __ARGS((void));
76 void free_termoptions __ARGS((void));
77 + void free_one_termoption __ARGS((char_u *var));
78 void set_term_defaults __ARGS((void));
79 void comp_col __ARGS((void));
80 char_u *get_equalprg __ARGS((void));
81 *** ../vim-7.2.237/src/term.c 2009-06-16 14:31:56.000000000 +0200
82 --- src/term.c 2009-07-22 13:19:59.000000000 +0200
86 /* if 'Sb' and 'AB' are not defined, reset "Co" */
87 if (*T_CSB == NUL && *T_CAB == NUL)
88 ! T_CCO = empty_option;
90 /* Set 'weirdinvert' according to value of 't_xs' */
91 p_wiv = (*T_XS != NUL);
94 /* if 'Sb' and 'AB' are not defined, reset "Co" */
95 if (*T_CSB == NUL && *T_CAB == NUL)
96 ! free_one_termoption(T_CCO);
98 /* Set 'weirdinvert' according to value of 't_xs' */
99 p_wiv = (*T_XS != NUL);
100 *** ../vim-7.2.237/src/version.c 2009-07-22 13:27:50.000000000 +0200
101 --- src/version.c 2009-07-22 14:25:44.000000000 +0200
105 { /* Add new patch number below this line */
111 hundred-and-one symptoms of being an internet addict:
112 95. Only communication in your household is through email.
114 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
115 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
116 \\\ download, build and distribute -- http://www.A-A-P.org ///
117 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///