aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/encode.c
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2016-02-11 01:38:58 +0300
committerZyX <kp-pav@yandex.ru>2016-04-18 02:47:13 +0300
commit4913a25dec5edc8888579a0f09a1b2f5f783c911 (patch)
treeb3bbd2db1507aebf85c7af290958fb476192c3bb /src/nvim/eval/encode.c
parent209427e97224ea7fdd49eb53fa41e0b26c55369f (diff)
downloadrneovim-4913a25dec5edc8888579a0f09a1b2f5f783c911.tar.gz
rneovim-4913a25dec5edc8888579a0f09a1b2f5f783c911.tar.bz2
rneovim-4913a25dec5edc8888579a0f09a1b2f5f783c911.zip
eval/encode: Free memory just in case
After string_convert() with .vc_fail=true these blocks should never be entered because they indicate invalid unicode.
Diffstat (limited to 'src/nvim/eval/encode.c')
-rw-r--r--src/nvim/eval/encode.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index 4d6a0afe9c..0096d9172b 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -927,12 +927,14 @@ static inline int convert_to_json_string(garray_T *const gap,
emsgf(_("E474: String \"%.*s\" contains byte that does not start "
"any UTF-8 character"),
utf_len - (i - shift), utf_buf + i - shift);
+ xfree(tofree);
return FAIL;
} else if ((SURROGATE_HI_START <= ch && ch <= SURROGATE_HI_END)
|| (SURROGATE_LO_START <= ch && ch <= SURROGATE_LO_END)) {
emsgf(_("E474: UTF-8 string contains code point which belongs "
"to a surrogate pair: %.*s"),
utf_len - (i - shift), utf_buf + i - shift);
+ xfree(tofree);
return FAIL;
} else if (ENCODE_RAW(p_enc_conv, ch)) {
str_len += shift;