summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-22 20:30:27 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-22 20:30:27 +0200
commit25fd2672875351ff56a925284a03a900081f70c0 (patch)
treeaba8689649e09141a54b0dcee79e26d3a9301e96
parentb2b218d89b3a6f450e65afd5e59ac234a5fa1eb7 (diff)
patch 8.2.1039: cannot put NUL byte on clipboardv8.2.1039
Problem: Cannot put NUL byte on clipboard. Solution: Use the text length. (Christian Brabandt, closes #6312, closes #6149)
-rw-r--r--src/testdir/test_registers.vim18
-rw-r--r--src/version.c2
-rw-r--r--src/winclip.c4
3 files changed, 22 insertions, 2 deletions
diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim
index c9135628c0..d92ad977f1 100644
--- a/src/testdir/test_registers.vim
+++ b/src/testdir/test_registers.vim
@@ -641,4 +641,22 @@ func Test_execute_reg_as_ex_cmd()
call assert_equal(repeat('abcdefghijklmnopqrstuvwxyz', 312), str)
endfunc
+" Test for clipboard registers with ASCII NUL
+func Test_clipboard_nul()
+ CheckFeature clipboard_working
+ new
+
+ " Test for putting ASCII NUL into the clipboard
+ set clipboard=unnamed
+ call append(0, "\ntest")
+ normal ggyyp
+ call assert_equal("^@test^@", strtrans(getreg('*')))
+ call assert_equal(getline(1), getline(2))
+ let b = split(execute(":reg *"), "\n")
+ call assert_match('"\*\s*\^@test\^J',b[1])
+
+ set clipboard&vim
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index b383830c95..d6ed2cd972 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1039,
+/**/
1038,
/**/
1037,
diff --git a/src/winclip.c b/src/winclip.c
index 767bf1c71e..db88e6787d 100644
--- a/src/winclip.c
+++ b/src/winclip.c
@@ -422,7 +422,7 @@ clip_mch_request_selection(Clipboard_T *cbd)
}
}
- if (str != NULL && *str != NUL)
+ if (str != NULL && metadata.txtlen != 0)
{
char_u *temp_clipboard;
@@ -543,7 +543,7 @@ clip_mch_set_selection(Clipboard_T *cbd)
if (lpszMem)
{
- vim_strncpy((char_u *)lpszMem, str, metadata.txtlen);
+ mch_memmove((char_u *)lpszMem, str, metadata.txtlen);
GlobalUnlock(hMem);
}
}