Skip to content

Commit 8211798

Browse files
committed
patch 7.4.2270
Problem: Insufficient testing for NUL bytes on a raw channel. Solution: Add a test for writing and reading.
1 parent e17bdff commit 8211798

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/testdir/test_channel.vim

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ func Test_using_freed_memory()
13211321
endfunc
13221322

13231323
func Test_collapse_buffers()
1324-
if !executable('cat')
1324+
if !executable('cat') || !has('job')
13251325
return
13261326
endif
13271327
sp test_channel.vim
@@ -1335,6 +1335,42 @@ func Test_collapse_buffers()
13351335
bwipe!
13361336
endfunc
13371337

1338+
func Test_raw_passes_nul()
1339+
if !executable('cat') || !has('job')
1340+
return
1341+
endif
1342+
1343+
" Test lines from the job containing NUL are stored correctly in a buffer.
1344+
new
1345+
call setline(1, ["asdf\nasdf", "xxx\n", "\nyyy"])
1346+
w! Xtestread
1347+
bwipe!
1348+
split testout
1349+
1,$delete
1350+
call job_start('cat Xtestread', {'out_io': 'buffer', 'out_name': 'testout'})
1351+
call WaitFor('line("$") > 2')
1352+
call assert_equal("asdf\nasdf", getline(2))
1353+
call assert_equal("xxx\n", getline(3))
1354+
call assert_equal("\nyyy", getline(4))
1355+
1356+
call delete('Xtestread')
1357+
bwipe!
1358+
1359+
" Test lines from a buffer with NUL bytes are written correctly to the job.
1360+
new mybuffer
1361+
call setline(1, ["asdf\nasdf", "xxx\n", "\nyyy"])
1362+
let g:Ch_job = job_start('cat', {'in_io': 'buffer', 'in_name': 'mybuffer', 'out_io': 'file', 'out_name': 'Xtestwrite'})
1363+
call WaitFor('"dead" == job_status(g:Ch_job)')
1364+
bwipe!
1365+
split Xtestwrite
1366+
call assert_equal("asdf\nasdf", getline(1))
1367+
call assert_equal("xxx\n", getline(2))
1368+
call assert_equal("\nyyy", getline(3))
1369+
1370+
call delete('Xtestwrite')
1371+
bwipe!
1372+
endfunc
1373+
13381374
function Ch_test_close_lambda(port)
13391375
let handle = ch_open('localhost:' . a:port, s:chopt)
13401376
if ch_status(handle) == "fail"

src/version.c

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

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2270,
766768
/**/
767769
2269,
768770
/**/

0 commit comments

Comments
 (0)