summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1411
blob: 61078ab87da441a3edac004eff7f7d428828ae8c (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
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1411
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.1411
Problem:    Coverity warns for divide by zero.
Solution:   Make sure width is larger than zero.
Files:	    src/charset.c


*** ../vim-8.1.1410/src/charset.c	2019-05-24 18:48:36.750128544 +0200
--- src/charset.c	2019-05-27 21:59:46.180472213 +0200
***************
*** 1105,1119 ****
  	    {
  		if (size + sbrlen + numberwidth > (colnr_T)wp->w_width)
  		{
! 		    /* calculate effective window width */
  		    int width = (colnr_T)wp->w_width - sbrlen - numberwidth;
  		    int prev_width = col
  				 ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0;
! 		    if (width == 0)
! 			width = (colnr_T)wp->w_width;
  		    added += ((size - prev_width) / width) * vim_strsize(p_sbr);
  		    if ((size - prev_width) % width)
! 			/* wrapped, add another length of 'sbr' */
  			added += vim_strsize(p_sbr);
  		}
  		else
--- 1105,1120 ----
  	    {
  		if (size + sbrlen + numberwidth > (colnr_T)wp->w_width)
  		{
! 		    // calculate effective window width
  		    int width = (colnr_T)wp->w_width - sbrlen - numberwidth;
  		    int prev_width = col
  				 ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0;
! 
! 		    if (width <= 0)
! 			width = (colnr_T)1;
  		    added += ((size - prev_width) / width) * vim_strsize(p_sbr);
  		    if ((size - prev_width) % width)
! 			// wrapped, add another length of 'sbr'
  			added += vim_strsize(p_sbr);
  		}
  		else
*** ../vim-8.1.1410/src/version.c	2019-05-27 21:53:53.990229301 +0200
--- src/version.c	2019-05-27 22:00:33.300237524 +0200
***************
*** 769,770 ****
--- 769,772 ----
  {   /* Add new patch number below this line */
+ /**/
+     1411,
  /**/

-- 
On the other hand, you have different fingers.
                                      -- Steven Wright

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///