]> granicus.if.org Git - vim/commitdiff
patch 8.0.0084 v8.0.0084
authorBram Moolenaar <Bram@vim.org>
Sun, 13 Nov 2016 14:09:26 +0000 (15:09 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 13 Nov 2016 14:09:26 +0000 (15:09 +0100)
Problem:    Using freed memory when adding to a quickfix list. (Domenique
            Pelle)
Solution:   Clear the directory name.

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 58c4227b6ae5aaff7fc01ba5672cb884cd4d5b1a..df351634f5c23f5efc678f4c3969eb924effcbf3 100644 (file)
@@ -1617,7 +1617,7 @@ static char_u *qf_last_bufname = NULL;
 static bufref_T  qf_last_bufref = {NULL, 0};
 
 /*
- * Get buffer number for file "directory.fname".
+ * Get buffer number for file "directory/fname".
  * Also sets the b_has_qf_entry flag.
  */
     static int
@@ -2711,7 +2711,9 @@ qf_free(qf_info_T *qi, int idx)
     qi->qf_lists[idx].qf_index = 0;
 
     qf_clean_dir_stack(&qi->qf_dir_stack);
+    qi->qf_directory = NULL;
     qf_clean_dir_stack(&qi->qf_file_stack);
+    qi->qf_currfile = NULL;
 }
 
 /*
index 98afdb159366636579d8e126a91e32f12caf7af3..13c1482dd262952054fccac32330129e0884c56a 100644 (file)
@@ -1669,3 +1669,25 @@ func Test_caddexpr_wrong()
   call assert_fails('caddexpr ""', 'E376:')
   let &efm = save_efm
 endfunc
+
+func Test_dirstack_cleanup()
+  " This used to cause a memory access in freed memory.
+  let save_efm = &efm
+  lexpr '0'
+  lopen
+  fun X(c)
+    let save_efm=&efm
+    set efm=%D%f
+    if a:c == 'c'
+      caddexpr '::'
+    else
+      laddexpr ':0:0'
+    endif
+    let &efm=save_efm
+  endfun
+  call X('c')
+  call X('l')
+  call setqflist([], 'r')
+  caddbuffer
+  let &efm = save_efm
+endfunc
index c7f00a8764065dc4d4c3931efd6737b51f64c91b..c4013e790c82e14c976877f1564b99ba1191fedb 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    84,
 /**/
     83,
 /**/