summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.273
blob: ac00afaa798ae024f611c134f2a69e9c170ee0ed (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
118
119
120
121
122
123
124
125
126
127
128
129
130
To: vim-dev@vim.org
Subject: Patch 7.2.273
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.273
Problem:    Crash with redir to unknown array. (Christian Brabandt)
Solution:   Don't assign the redir result when there was an error.
Files:	    src/eval.c


*** ../vim-7.2.272/src/eval.c	2009-09-30 15:15:33.000000000 +0200
--- src/eval.c	2009-11-03 12:05:07.000000000 +0100
***************
*** 988,1000 ****
      int		err;
      typval_T	tv;
  
!     /* Make sure a valid variable name is specified */
      if (!eval_isnamec1(*name))
      {
  	EMSG(_(e_invarg));
  	return FAIL;
      }
  
      redir_varname = vim_strsave(name);
      if (redir_varname == NULL)
  	return FAIL;
--- 988,1001 ----
      int		err;
      typval_T	tv;
  
!     /* Catch a bad name early. */
      if (!eval_isnamec1(*name))
      {
  	EMSG(_(e_invarg));
  	return FAIL;
      }
  
+     /* Make a copy of the name, it is used in redir_lval until redir ends. */
      redir_varname = vim_strsave(name);
      if (redir_varname == NULL)
  	return FAIL;
***************
*** 1019,1024 ****
--- 1020,1026 ----
  	    EMSG(_(e_trailing));
  	else
  	    EMSG(_(e_invarg));
+ 	redir_endp = NULL;  /* don't store a value, only cleanup */
  	var_redir_stop();
  	return FAIL;
      }
***************
*** 1037,1042 ****
--- 1039,1045 ----
      did_emsg |= save_emsg;
      if (err)
      {
+ 	redir_endp = NULL;  /* don't store a value, only cleanup */
  	var_redir_stop();
  	return FAIL;
      }
***************
*** 1085,1090 ****
--- 1088,1094 ----
  
  /*
   * Stop redirecting command output to a variable.
+  * Frees the allocated memory.
   */
      void
  var_redir_stop()
***************
*** 1093,1106 ****
  
      if (redir_lval != NULL)
      {
! 	/* Append the trailing NUL. */
! 	ga_append(&redir_ga, NUL);
  
! 	/* Assign the text to the variable. */
! 	tv.v_type = VAR_STRING;
! 	tv.vval.v_string = redir_ga.ga_data;
! 	set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
! 	vim_free(tv.vval.v_string);
  
  	clear_lval(redir_lval);
  	vim_free(redir_lval);
--- 1097,1114 ----
  
      if (redir_lval != NULL)
      {
! 	/* If there was no error: assign the text to the variable. */
! 	if (redir_endp != NULL)
! 	{
! 	    ga_append(&redir_ga, NUL);  /* Append the trailing NUL. */
! 	    tv.v_type = VAR_STRING;
! 	    tv.vval.v_string = redir_ga.ga_data;
! 	    set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
! 	}
  
! 	/* free the collected output */
! 	vim_free(redir_ga.ga_data);
! 	redir_ga.ga_data = NULL;
  
  	clear_lval(redir_lval);
  	vim_free(redir_lval);
*** ../vim-7.2.272/src/version.c	2009-11-03 13:06:03.000000000 +0100
--- src/version.c	2009-11-03 14:24:06.000000000 +0100
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     273,
  /**/

-- 
Permission is granted to read this message out aloud on Kings Cross Road,
London, under the condition that the orator is properly dressed.

 /// 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    ///