mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	vim-patch:9.1.1260: Hang when filtering buffer with NUL bytes (#33192)
Problem: Hang when filtering buffer with NUL bytes (after 9.1.1050). Solution: Don't subtract "written" from "lplen" repeatedly (zeertzjq). related: neovim/neovim#33173 closes: vim/vim#1701153fed23cb7(cherry picked from commit431c037709)
This commit is contained in:
		
				
					committed by
					
						
						github-actions[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							7efb3ba6f7
						
					
				
				
					commit
					2084cda6f9
				
			@@ -1211,7 +1211,6 @@ static void read_input(StringBuilder *buf)
 | 
			
		||||
  size_t lplen = (size_t)ml_get_len(lnum);
 | 
			
		||||
 | 
			
		||||
  while (true) {
 | 
			
		||||
    lplen -= written;
 | 
			
		||||
    if (lplen == 0) {
 | 
			
		||||
      len = 0;
 | 
			
		||||
    } else if (lp[written] == NL) {
 | 
			
		||||
@@ -1220,11 +1219,11 @@ static void read_input(StringBuilder *buf)
 | 
			
		||||
      kv_push(*buf, NUL);
 | 
			
		||||
    } else {
 | 
			
		||||
      char *s = vim_strchr(lp + written, NL);
 | 
			
		||||
      len = s == NULL ? lplen : (size_t)(s - (lp + written));
 | 
			
		||||
      len = s == NULL ? lplen - written : (size_t)(s - (lp + written));
 | 
			
		||||
      kv_concat_len(*buf, lp + written, len);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (len == lplen) {
 | 
			
		||||
    if (len == lplen - written) {
 | 
			
		||||
      // Finished a line, add a NL, unless this line should not have one.
 | 
			
		||||
      if (lnum != curbuf->b_op_end.lnum
 | 
			
		||||
          || (!curbuf->b_p_bin && curbuf->b_p_fixeol)
 | 
			
		||||
 
 | 
			
		||||
@@ -281,4 +281,18 @@ func Test_shell_no_prevcmd()
 | 
			
		||||
  call delete('Xtestdone')
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_shell_filter_buffer_with_nul_bytes()
 | 
			
		||||
  CheckUnix
 | 
			
		||||
  new
 | 
			
		||||
  set noshelltemp
 | 
			
		||||
  " \n is a NUL byte
 | 
			
		||||
  let lines = ["aaa\nbbb\nccc\nddd\neee", "fff\nggg\nhhh\niii\njjj"]
 | 
			
		||||
  call setline(1, lines)
 | 
			
		||||
  %!cat
 | 
			
		||||
  call assert_equal(lines, getline(1, '$'))
 | 
			
		||||
 | 
			
		||||
  set shelltemp&
 | 
			
		||||
  bwipe!
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
" vim: shiftwidth=2 sts=2 expandtab
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user