Patch 8.1.1158
Problem: Json encoded string is sometimes missing the final NUL.
Solution: Add the NUL. Also for log messages.
Files: src/json.c, src/channel.c, src/testdir/test_json.vim
*** ../vim-8.1.1157/src/json.c 2019-01-24 15:54:17.786847003 +0100
--- src/json.c 2019-04-12 21:10:55.244430796 +0200
***************
*** 51,56 ****
--- 51,57 ----
/* 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,87 ****
--- 83,89 ----
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
*** ../vim-8.1.1157/src/channel.c 2019-03-21 21:45:30.883282076 +0100
--- src/channel.c 2019-04-12 21:14:02.015234496 +0200
***************
*** 5877,5882 ****
--- 5877,5883 ----
ga_concat(&ga, (char_u *)" ");
ga_concat(&ga, (char_u *)argv[i]);
}
+ ga_append(&ga, NUL);
ch_log(NULL, "Starting job: %s", (char *)ga.ga_data);
ga_clear(&ga);
}
*** ../vim-8.1.1157/src/testdir/test_json.vim 2019-01-24 17:59:35.139217458
+0100
--- src/testdir/test_json.vim 2019-04-12 21:06:44.574119544 +0200
***************
*** 289,291 ****
--- 289,298 ----
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
*** ../vim-8.1.1157/src/version.c 2019-04-12 20:08:51.478186362 +0200
--- src/version.c 2019-04-12 21:18:53.745431937 +0200
***************
*** 773,774 ****
--- 773,776 ----
{ /* Add new patch number below this line */
+ /**/
+ 1158,
/**/
--
hundred-and-one symptoms of being an internet addict:
262. Your computer has it's own phone line - but your daughter doesn't.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.