Mercurial > vim
comparison src/testdir/test_substitute.vim @ 18576:e9675870c480 v8.1.2282
patch 8.1.2282: crash when passing many arguments through a partial
Commit: https://github.com/vim/vim/commit/4c054e9fb23027b55a09ee647a3a2c91936aeb1b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 10 00:13:50 2019 +0100
patch 8.1.2282: crash when passing many arguments through a partial
Problem: Crash when passing many arguments through a partial. (Andy
Massimino)
Solution: Check the number of arguments. (closes #5186)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 Nov 2019 00:15:04 +0100 |
parents | 23fef64352a1 |
children | b8fd7364befd |
comparison
equal
deleted
inserted
replaced
18575:a5f35d5b839f | 18576:e9675870c480 |
---|---|
406 endfunc | 406 endfunc |
407 | 407 |
408 func SubReplacer(text, submatches) | 408 func SubReplacer(text, submatches) |
409 return a:text .. a:submatches[0] .. a:text | 409 return a:text .. a:submatches[0] .. a:text |
410 endfunc | 410 endfunc |
411 func SubReplacer20(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, submatches) | |
412 return a:t3 .. a:submatches[0] .. a:t11 | |
413 endfunc | |
411 | 414 |
412 func Test_substitute_partial() | 415 func Test_substitute_partial() |
413 call assert_equal('1foo2foo3', substitute('123', '2', function('SubReplacer', ['foo']), 'g')) | 416 call assert_equal('1foo2foo3', substitute('123', '2', function('SubReplacer', ['foo']), 'g')) |
417 | |
418 " 19 arguments plus one is just OK | |
419 let Replacer = function('SubReplacer20', repeat(['foo'], 19)) | |
420 call assert_equal('1foo2foo3', substitute('123', '2', Replacer, 'g')) | |
421 | |
422 " 20 arguments plus one is too many | |
423 let Replacer = function('SubReplacer20', repeat(['foo'], 20)) | |
424 call assert_fails("call substitute('123', '2', Replacer, 'g')", 'E118') | |
414 endfunc | 425 endfunc |
415 | 426 |
416 " Tests for *sub-replace-special* and *sub-replace-expression* on :substitute. | 427 " Tests for *sub-replace-special* and *sub-replace-expression* on :substitute. |
417 | 428 |
418 " Execute a list of :substitute command tests | 429 " Execute a list of :substitute command tests |