summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1158
blob: a3574ecb1c78e268bd287b2e0140bf0efb1d0ab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1158
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

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 -- Bram@Moolenaar.net -- 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    ///