1
0
forked from aniani/vim

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.
This commit is contained in:
Bram Moolenaar
2019-04-12 21:19:04 +02:00
parent f9b89b4679
commit 04af19637c
4 changed files with 12 additions and 0 deletions

View File

@@ -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 *val, int options)
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