summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.2.238
blob: a70976d8fae98a93b65e3b84c487f871e01fbf42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
To: vim-dev@vim.org
Subject: Patch 7.2.238
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.238
Problem:    Leaking memory when setting term to "builtin_dumb".
Solution:   Free memory when resetting term option t_Co.
Files:	    src/option.c, src/proto/option.pro, src/term.c


*** ../vim-7.2.237/src/option.c	2009-06-16 17:50:56.000000000 +0200
--- src/option.c	2009-07-22 12:49:19.000000000 +0200
***************
*** 403,410 ****
  #define P_NUM		0x02	/* the option is numeric */
  #define P_STRING	0x04	/* the option is a string */
  #define P_ALLOCED	0x08	/* the string option is in allocated memory,
! 				    must use vim_free() when assigning new
! 				    value. Not set if default is the same. */
  #define P_EXPAND	0x10	/* environment expansion.  NOTE: P_EXPAND can
  				   never be used for local or hidden options! */
  #define P_NODEFAULT	0x40	/* don't set to default value */
--- 403,411 ----
  #define P_NUM		0x02	/* the option is numeric */
  #define P_STRING	0x04	/* the option is a string */
  #define P_ALLOCED	0x08	/* the string option is in allocated memory,
! 				   must use free_string_option() when
! 				   assigning new value. Not set if default is
! 				   the same. */
  #define P_EXPAND	0x10	/* environment expansion.  NOTE: P_EXPAND can
  				   never be used for local or hidden options! */
  #define P_NODEFAULT	0x40	/* don't set to default value */
***************
*** 8927,8932 ****
--- 8928,8955 ----
  }
  
  /*
+  * Free the string for one term option, if it was allocated.
+  * Set the string to empty_option and clear allocated flag.
+  * "var" points to the option value.
+  */
+     void
+ free_one_termoption(var)
+     char_u *var;
+ {
+     struct vimoption   *p;
+ 
+     for (p = &options[0]; p->fullname != NULL; p++)
+ 	if (p->var == var)
+ 	{
+ 	    if (p->flags & P_ALLOCED)
+ 		free_string_option(*(char_u **)(p->var));
+ 	    *(char_u **)(p->var) = empty_option;
+ 	    p->flags &= ~P_ALLOCED;
+ 	    break;
+ 	}
+ }
+ 
+ /*
   * Set the terminal option defaults to the current value.
   * Used after setting the terminal name.
   */
*** ../vim-7.2.237/src/proto/option.pro	2009-02-21 20:27:00.000000000 +0100
--- src/proto/option.pro	2009-07-22 12:52:31.000000000 +0200
***************
*** 29,34 ****
--- 29,35 ----
  int makefoldset __ARGS((FILE *fd));
  void clear_termoptions __ARGS((void));
  void free_termoptions __ARGS((void));
+ void free_one_termoption __ARGS((char_u *var));
  void set_term_defaults __ARGS((void));
  void comp_col __ARGS((void));
  char_u *get_equalprg __ARGS((void));
*** ../vim-7.2.237/src/term.c	2009-06-16 14:31:56.000000000 +0200
--- src/term.c	2009-07-22 13:19:59.000000000 +0200
***************
*** 2881,2887 ****
  
  	/* if 'Sb' and 'AB' are not defined, reset "Co" */
  	if (*T_CSB == NUL && *T_CAB == NUL)
! 	    T_CCO = empty_option;
  
  	/* Set 'weirdinvert' according to value of 't_xs' */
  	p_wiv = (*T_XS != NUL);
--- 2881,2887 ----
  
  	/* if 'Sb' and 'AB' are not defined, reset "Co" */
  	if (*T_CSB == NUL && *T_CAB == NUL)
! 	    free_one_termoption(T_CCO);
  
  	/* Set 'weirdinvert' according to value of 't_xs' */
  	p_wiv = (*T_XS != NUL);
*** ../vim-7.2.237/src/version.c	2009-07-22 13:27:50.000000000 +0200
--- src/version.c	2009-07-22 14:25:44.000000000 +0200
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     238,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
95. Only communication in your household is through email.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///