summaryrefslogtreecommitdiff
blob: 49b70b963b356ef21c3e1ec22b272b13edaa0363 (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
To: vim-dev@vim.org
Subject: Patch 6.0.019
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 6.0.019
Problem:    Converting a string with multi-byte characters to a printable
	    string, e.g., with strtrans(), may cause a crash. (Tomas Zellerin)
Solution:   Correctly compute the length of the result in transstr().
Files:	    src/charset.c


*** ../vim60.18/src/charset.c	Wed Sep 19 17:28:08 2001
--- src/charset.c	Mon Oct 22 12:43:03 2001
***************
*** 327,351 ****
      char_u	*s;
  {
      char_u	*res;
  #ifdef FEAT_MBYTE
!     int		l;
  #endif
  
!     res = alloc((unsigned)(vim_strsize(s) + 1));
      if (res != NULL)
      {
  	*res = NUL;
! 	while (*s != NUL)
  	{
  #ifdef FEAT_MBYTE
! 	    if (has_mbyte && (l = (*mb_ptr2len_check)(s)) > 1)
  	    {
! 		STRNCAT(res, s, l);
! 		s += l;
  	    }
  	    else
  #endif
! 		STRCAT(res, transchar(*s++));
  	}
      }
      return res;
--- 327,374 ----
      char_u	*s;
  {
      char_u	*res;
+     char_u	*p;
  #ifdef FEAT_MBYTE
!     int		l, len;
  #endif
  
! #ifdef FEAT_MBYTE
!     if (has_mbyte)
!     {
! 	/* Compute the length of the result, taking into account that
! 	 * multi-byte characters are copied unchanged. */
! 	len = 0;
! 	p = s;
! 	while (*p != NUL)
! 	{
! 	    if ((l = (*mb_ptr2len_check)(p)) > 1)
! 	    {
! 		len += l;
! 		p += l;
! 	    }
! 	    else
! 		len += byte2cells(*p++);
! 	}
! 	res = alloc((unsigned)(len + 1));
!     }
!     else
! #endif
! 	res = alloc((unsigned)(vim_strsize(s) + 1));
      if (res != NULL)
      {
  	*res = NUL;
! 	p = s;
! 	while (*p != NUL)
  	{
  #ifdef FEAT_MBYTE
! 	    if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
  	    {
! 		STRNCAT(res, p, l);
! 		p += l;
  	    }
  	    else
  #endif
! 		STRCAT(res, transchar(*p++));
  	}
      }
      return res;
*** ../vim60.18/src/version.c	Mon Oct 22 12:47:09 2001
--- src/version.c	Mon Oct 22 12:46:56 2001
***************
*** 608,609 ****
--- 608,611 ----
  {   /* Add new patch number below this line */
+ /**/
+     19,
  /**/

-- 
"Hit any key to continue" is very confusing when you have two keyboards.

 ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
(((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
 \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///