Patch 8.0.1602
Problem: Crash in parsing JSON.
Solution: Fail when using array or dict as dict key. (Damien)
Files: src/json.c, src/testdir/test_json.vim
*** ../vim-8.0.1601/src/json.c 2017-12-15 21:24:56.241651799 +0100
--- src/json.c 2018-03-13 13:06:11.249902651 +0100
***************
*** 621,627 ****
if (top_item != NULL && top_item->jd_type == JSON_OBJECT_KEY
&& (options & JSON_JS)
&& reader->js_buf[reader->js_used] != '"'
! && reader->js_buf[reader->js_used] != '\'')
{
char_u *key;
--- 621,629 ----
if (top_item != NULL && top_item->jd_type == JSON_OBJECT_KEY
&& (options & JSON_JS)
&& reader->js_buf[reader->js_used] != '"'
! && reader->js_buf[reader->js_used] != '\''
! && reader->js_buf[reader->js_used] != '['
! && reader->js_buf[reader->js_used] != '{')
{
char_u *key;
***************
*** 642,647 ****
--- 644,654 ----
switch (*p)
{
case '[': /* start of array */
+ if (top_item && top_item->jd_type == JSON_OBJECT_KEY)
+ {
+ retval = FAIL;
+ break;
+ }
if (ga_grow(&stack, 1) == FAIL)
{
retval = FAIL;
***************
*** 668,673 ****
--- 675,685 ----
continue;
case '{': /* start of object */
+ if (top_item && top_item->jd_type == JSON_OBJECT_KEY)
+ {
+ retval = FAIL;
+ break;
+ }
if (ga_grow(&stack, 1) == FAIL)
{
retval = FAIL;
*** ../vim-8.0.1601/src/testdir/test_json.vim 2017-12-15 21:24:56.241651799
+0100
--- src/testdir/test_json.vim 2018-03-13 13:06:11.253902627 +0100
***************
*** 179,184 ****
--- 179,187 ----
call assert_fails('call json_decode("[1 2]")', "E474:")
call assert_fails('call json_decode("[1,,2]")', "E474:")
+
+ call assert_fails('call json_decode("{{}:42}")', "E474:")
+ call assert_fails('call json_decode("{[]:42}")', "E474:")
endfunc
let s:jsl5 = '[7,,,]'
*** ../vim-8.0.1601/src/version.c 2018-03-12 22:16:33.261746681 +0100
--- src/version.c 2018-03-13 13:09:11.056808637 +0100
***************
*** 768,769 ****
--- 768,771 ----
{ /* Add new patch number below this line */
+ /**/
+ 1602,
/**/
--
A)bort, R)etry, B)ang it with a large hammer
/// 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.