diff src/json.c @ 16306:a2c598cbe220 v8.1.1158

patch 8.1.1158: json encoded string is sometimes missing the final NUL commit https://github.com/vim/vim/commit/04af19637c14045fa33b99576de4eea1e3524edb Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 12 21:19:04 2019 +0200 patch 8.1.1158: json encoded string is sometimes missing the final NUL Problem: Json encoded string is sometimes missing the final NUL. Solution: Add the NUL. Also for log messages.
author Bram Moolenaar <Bram@vim.org>
date Fri, 12 Apr 2019 21:30:04 +0200
parents 536dd2bc5ac9
children 77bcb5055fec
line wrap: on
line diff
--- a/src/json.c
+++ b/src/json.c
@@ -51,6 +51,7 @@ json_encode(typval_T *val, int options)
     /* Store bytes in the growarray. */
     ga_init2(&ga, 1, 4000);
     json_encode_gap(&ga, val, options);
+    ga_append(&ga, NUL);
     return ga.ga_data;
 }
 
@@ -82,6 +83,7 @@ json_encode_nr_expr(int nr, typval_T *va
     if (json_encode_gap(&ga, &listtv, options) == OK && (options & JSON_NL))
 	ga_append(&ga, '\n');
     list_unref(listtv.vval.v_list);
+    ga_append(&ga, NUL);
     return ga.ga_data;
 }
 #endif