summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0261
blob: 161598204130a7f6199347fed8069c02c6597857 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0261
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.0261
Problem:    Coverity complains about a negative array index.
Solution:   When qf_id2nr() cannot find the list then don't set qf_curlist.
Files:	    src/quickfix.c


*** ../vim-8.1.0260/src/quickfix.c	2018-08-09 21:19:15.774436077 +0200
--- src/quickfix.c	2018-08-09 21:49:36.929501416 +0200
***************
*** 2011,2023 ****
  {
      qf_info_T *qi;
  
!     qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
      if (qi != NULL)
-     {
- 	vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
  	qi->qf_refcount++;
-     }
- 
      return qi;
  }
  
--- 2011,2019 ----
  {
      qf_info_T *qi;
  
!     qi = (qf_info_T *)alloc_clear((unsigned)sizeof(qf_info_T));
      if (qi != NULL)
  	qi->qf_refcount++;
      return qi;
  }
  
***************
*** 4339,4352 ****
  }
  
  /*
   * Jump to the first entry if there is one.
   */
      static void
  qf_jump_first(qf_info_T *qi, int_u save_qfid, int forceit)
  {
!     // If autocommands changed the current list, then restore it
!     if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid)
! 	qi->qf_curlist = qf_id2nr(qi, save_qfid);
  
      // Autocommands might have cleared the list, check for it
      if (!qf_list_empty(qi, qi->qf_curlist))
--- 4335,4365 ----
  }
  
  /*
+  * If the current list is not "save_qfid" and we can find the list with that ID
+  * then make it the current list.
+  * This is used when autocommands may have changed the current list.
+  */
+     static void
+ qf_restore_list(qf_info_T *qi, int_u save_qfid)
+ {
+     int curlist;
+ 
+     if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid)
+     {
+ 	curlist = qf_id2nr(qi, save_qfid);
+ 	if (curlist >= 0)
+ 	    qi->qf_curlist = curlist;
+ 	// else: what if the list can't be found?
+     }
+ }
+ 
+ /*
   * Jump to the first entry if there is one.
   */
      static void
  qf_jump_first(qf_info_T *qi, int_u save_qfid, int forceit)
  {
!     qf_restore_list(qi, save_qfid);
  
      // Autocommands might have cleared the list, check for it
      if (!qf_list_empty(qi, qi->qf_curlist))
***************
*** 5012,5021 ****
  	}
      }
  
!     if (qi->qf_lists[qi->qf_curlist].qf_id != qfid)
! 	/* Autocommands changed the quickfix list.  Find the one we were
! 	 * using and restore it. */
! 	qi->qf_curlist = qf_id2nr(qi, qfid);
  
      return TRUE;
  }
--- 5025,5031 ----
  	}
      }
  
!     qf_restore_list(qi, qfid);
  
      return TRUE;
  }
***************
*** 5361,5369 ****
      if (!qflist_valid(wp, save_qfid))
  	goto theend;
  
!     // If autocommands changed the current list, then restore it
!     if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid)
! 	qi->qf_curlist = qf_id2nr(qi, save_qfid);
  
      /* Jump to first match. */
      if (!qf_list_empty(qi, qi->qf_curlist))
--- 5371,5377 ----
      if (!qflist_valid(wp, save_qfid))
  	goto theend;
  
!     qf_restore_list(qi, save_qfid);
  
      /* Jump to first match. */
      if (!qf_list_empty(qi, qi->qf_curlist))
***************
*** 5684,5695 ****
  	if (l == NULL)
  	    return FAIL;
  
! 	qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
  	if (qi != NULL)
  	{
- 	    vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
- 	    qi->qf_refcount++;
- 
  	    if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
  			TRUE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
  	    {
--- 5692,5700 ----
  	if (l == NULL)
  	    return FAIL;
  
! 	qi = ll_new_list();
  	if (qi != NULL)
  	{
  	    if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
  			TRUE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
  	    {
*** ../vim-8.1.0260/src/version.c	2018-08-09 21:33:34.800134541 +0200
--- src/version.c	2018-08-09 21:50:45.609022776 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     261,
  /**/

-- 
MONK: ... and the Lord spake, saying, "First shalt thou take out the Holy Pin,
      then shalt thou count to three, no more, no less.  Three shalt be the
      number thou shalt count, and the number of the counting shalt be three.
      Four shalt thou not count, neither count thou two, excepting that thou
      then proceed to three.  Five is right out.  Once the number three, being
      the third number, be reached, then lobbest thou thy Holy Hand Grenade of
      Antioch towards thou foe, who being naughty in my sight, shall snuff it.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

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