Skip to content

Commit 1223744

Browse files
committed
patch 8.0.1412: using free memory using setloclist()
Problem: Using free memory using setloclist(). (Dominique Pelle) Solution: Mark location list context as still in use when needed. (Yegappan Lakshmanan, closes #2462)
1 parent 2efb323 commit 1223744

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/quickfix.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5486,6 +5486,16 @@ set_ref_in_quickfix(int copyID)
54865486
if (abort)
54875487
return abort;
54885488
}
5489+
if (IS_LL_WINDOW(win) && (win->w_llist_ref->qf_refcount == 1))
5490+
{
5491+
/* In a location list window and none of the other windows is
5492+
* referring to this location list. Mark the location list
5493+
* context as still in use.
5494+
*/
5495+
abort = mark_quickfix_ctx(win->w_llist_ref, copyID);
5496+
if (abort)
5497+
return abort;
5498+
}
54895499
}
54905500

54915501
return abort;

src/testdir/test_quickfix.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,3 +3017,17 @@ func Test_qf_tick()
30173017
call Xqftick_tests('c')
30183018
call Xqftick_tests('l')
30193019
endfunc
3020+
3021+
" The following test used to crash Vim.
3022+
" Open the location list window and close the regular window associated with
3023+
" the location list. When the garbage collection runs now, it incorrectly
3024+
" marks the location list context as not in use and frees the context.
3025+
func Test_ll_window_ctx()
3026+
call setloclist(0, [], 'f')
3027+
call setloclist(0, [], 'a', {'context' : []})
3028+
lopen | only
3029+
call test_garbagecollect_now()
3030+
echo getloclist(0, {'context' : 1}).context
3031+
enew | only
3032+
endfunc
3033+

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1412,
774776
/**/
775777
1411,
776778
/**/

0 commit comments

Comments
 (0)