diff src/channel.c @ 9367:2465b6cda394 v7.4.1965

commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 27 21:10:31 2016 +0200 patch 7.4.1965 Problem: When using a job in raw mode to append to a buffer garbage characters are added. Solution: Do not replace the trailing NUL with a NL. (Ozaki Kiichi)
author Christian Brabandt <cb@256bit.org>
date Mon, 27 Jun 2016 21:15:05 +0200
parents 40c8a8b012b5
children 8f904a323b3f
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -1317,7 +1317,7 @@ write_buf_line(buf_T *buf, linenr_T lnum
     /* Need to make a copy to be able to append a NL. */
     if ((p = alloc(len + 2)) == NULL)
 	return;
-    STRCPY(p, line);
+    memcpy((char *)p, (char *)line, len);
     p[len] = NL;
     p[len + 1] = NUL;
     channel_send(channel, PART_IN, p, "write_buf_line()");
@@ -1616,7 +1616,7 @@ channel_get_all(channel_T *channel, int 
 {
     readq_T *head = &channel->ch_part[part].ch_head;
     readq_T *node = head->rq_next;
-    long_u  len = 1;
+    long_u  len = 0;
     char_u  *res;
     char_u  *p;
 
@@ -1627,7 +1627,7 @@ channel_get_all(channel_T *channel, int 
     /* Concatenate everything into one buffer. */
     for (node = head->rq_next; node != NULL; node = node->rq_next)
 	len += node->rq_buflen;
-    res = lalloc(len, TRUE);
+    res = lalloc(len + 1, TRUE);
     if (res == NULL)
 	return NULL;
     p = res;