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

@@ -289,3 +289,10 @@ func Test_js_decode()
call assert_equal(s:varl5, js_decode(s:jsl5))
endfunc
func Test_json_encode_long()
" The growarray uses a grow size of 4000, check that a result that is exactly
" 4000 bytes long is not missing the final NUL.
let json = json_encode([repeat('a', 3996)])
call assert_equal(4000, len(json))
endfunc