aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2016-02-09 03:20:16 +0300
committerZyX <kp-pav@yandex.ru>2016-04-18 02:47:13 +0300
commit77776b09c684bc2a0c42114fce5a8b04409ec91d (patch)
treede255689c5cc709b88e065b1a99bffed0e310ac0 /src
parentc27395ddc84952b94118de94af4c33f56f6beca5 (diff)
downloadrneovim-77776b09c684bc2a0c42114fce5a8b04409ec91d.tar.gz
rneovim-77776b09c684bc2a0c42114fce5a8b04409ec91d.tar.bz2
rneovim-77776b09c684bc2a0c42114fce5a8b04409ec91d.zip
eval/encode: Fix writing strings starting with NL to list
Error [found][1] by oni-link. [1]: https://github.com/neovim/neovim/pull/4131/files#r52239384
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.h2
-rw-r--r--src/nvim/eval/encode.c24
2 files changed, 11 insertions, 15 deletions
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index 50c11011c6..9d45b780a9 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -1,8 +1,6 @@
#ifndef NVIM_EVAL_H
#define NVIM_EVAL_H
-#include <msgpack.h>
-
#include "nvim/profile.h"
#include "nvim/hashtab.h" // For hashtab_T
#include "nvim/garray.h" // For garray_T
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index 8280889fbe..6026189235 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -79,11 +79,9 @@ int encode_list_write(void *data, const char *buf, size_t len)
do {
const char *line_start = line_end;
line_end = xmemscan(line_start, NL, (size_t) (end - line_start));
- if (line_end == line_start) {
- list_append_allocated_string(list, NULL);
- } else {
+ char *str = NULL;
+ if (line_end != line_start) {
const size_t line_length = (size_t) (line_end - line_start);
- char *str;
if (li == NULL) {
str = xmemdupz(line_start, line_length);
} else {
@@ -93,7 +91,7 @@ int encode_list_write(void *data, const char *buf, size_t len)
li->li_tv.vval.v_string = xrealloc(li->li_tv.vval.v_string,
li_len + line_length + 1);
str = (char *) li->li_tv.vval.v_string + li_len;
- memmove(str, line_start, line_length);
+ memcpy(str, line_start, line_length);
str[line_length] = 0;
}
for (size_t i = 0; i < line_length; i++) {
@@ -101,14 +99,14 @@ int encode_list_write(void *data, const char *buf, size_t len)
str[i] = NL;
}
}
- if (li == NULL) {
- list_append_allocated_string(list, str);
- } else {
- li = NULL;
- }
- if (line_end == end - 1) {
- list_append_allocated_string(list, NULL);
- }
+ }
+ if (li == NULL) {
+ list_append_allocated_string(list, str);
+ } else {
+ li = NULL;
+ }
+ if (line_end == end - 1) {
+ list_append_allocated_string(list, NULL);
}
line_end++;
} while (line_end < end);