Mercurial > vim
comparison src/testdir/test_ex_z.vim @ 11303:ef32a5c74515 v8.0.0537
patch 8.0.0537: illegal memory access with :z and large count
commit https://github.com/vim/vim/commit/fa0ad0bb0b4255e64ebcf9269d60a942e0ae7ff9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 2 15:45:17 2017 +0200
patch 8.0.0537: illegal memory access with :z and large count
Problem: Illegal memory access with :z and large count.
Solution: Check for number overflow, using long instead of int. (Dominique
Pelle, closes #1612)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 02 Apr 2017 16:00:05 +0200 |
parents | |
children | 1074f58e1673 |
comparison
equal
deleted
inserted
replaced
11302:e3ef35af5a08 | 11303:ef32a5c74515 |
---|---|
1 " Test :z | |
2 | |
3 func Test_z() | |
4 call setline(1, range(1, 100)) | |
5 | |
6 let a = execute('20z3') | |
7 call assert_equal("\n20\n21\n22", a) | |
8 call assert_equal(22, line('.')) | |
9 " 'window' should be set to the {count} value. | |
10 call assert_equal(3, &window) | |
11 | |
12 " If there is only one window, then twice the amount of 'scroll' is used. | |
13 set scroll=2 | |
14 let a = execute('20z') | |
15 call assert_equal("\n20\n21\n22\n23", a) | |
16 call assert_equal(23, line('.')) | |
17 | |
18 let a = execute('20z+3') | |
19 " FIXME: I would expect the same result as '20z3' but it | |
20 " gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"? | |
21 "call assert_equal("\n20\n21\n22", a) | |
22 "call assert_equal(22, line('.')) | |
23 | |
24 let a = execute('20z-3') | |
25 call assert_equal("\n18\n19\n20", a) | |
26 call assert_equal(20, line('.')) | |
27 | |
28 let a = execute('20z=3') | |
29 call assert_match("^\n18\n19\n-\\+\n20\n-\\+\n21\n22$", a) | |
30 call assert_equal(20, line('.')) | |
31 | |
32 let a = execute('20z^3') | |
33 call assert_equal("\n14\n15\n16\n17", a) | |
34 call assert_equal(17, line('.')) | |
35 | |
36 let a = execute('20z.3') | |
37 call assert_equal("\n19\n20\n21", a) | |
38 call assert_equal(21, line('.')) | |
39 | |
40 let a = execute('20z#3') | |
41 call assert_equal("\n 20 20\n 21 21\n 22 22", a) | |
42 call assert_equal(22, line('.')) | |
43 | |
44 let a = execute('20z#-3') | |
45 call assert_equal("\n 18 18\n 19 19\n 20 20", a) | |
46 call assert_equal(20, line('.')) | |
47 | |
48 let a = execute('20z#=3') | |
49 call assert_match("^\n 18 18\n 19 19\n-\\+\n 20 20\n-\\+\n 21 21\n 22 22$", a) | |
50 call assert_equal(20, line('.')) | |
51 | |
52 " Test with {count} bigger than the number of lines in buffer. | |
53 let a = execute('20z1000') | |
54 call assert_match("^\n20\n21\n.*\n99\n100$", a) | |
55 call assert_equal(100, line('.')) | |
56 | |
57 let a = execute('20z-1000') | |
58 call assert_match("^\n1\n2\n.*\n19\n20$", a) | |
59 call assert_equal(20, line('.')) | |
60 | |
61 let a = execute('20z=1000') | |
62 call assert_match("^\n1\n.*\n-\\+\n20\n-\\\+\n.*\n100$", a) | |
63 call assert_equal(20, line('.')) | |
64 | |
65 call assert_fails('20z=a', 'E144:') | |
66 | |
67 set window& scroll& | |
68 bw! | |
69 endfunc | |
70 | |
71 func Test_z_bug() | |
72 " This used to access invalid memory as a result of an integer overflow | |
73 " and freeze vim. | |
74 normal ox | |
75 normal Heat | |
76 z777777776666666 | |
77 ') | |
78 endfunc |