aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-05-25 17:13:23 -0400
committerJames McCoy <jamessan@jamessan.com>2016-05-25 21:02:52 -0400
commitccef5c9c77543fb0cf1b31c82fcb566cca7eff4c (patch)
tree78718e500714f9de44a207be334c1b731da7c2e4
parentbc306ab5aa0d2ee7a4653cb1d47615a3f04478a1 (diff)
downloadrneovim-ccef5c9c77543fb0cf1b31c82fcb566cca7eff4c.tar.gz
rneovim-ccef5c9c77543fb0cf1b31c82fcb566cca7eff4c.tar.bz2
rneovim-ccef5c9c77543fb0cf1b31c82fcb566cca7eff4c.zip
vim-patch:7.4.1567
Problem: Crash in assert_fails(). Solution: Check for NULL. (Dominique Pelle) Add a test. https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
-rw-r--r--src/nvim/eval.c3
-rw-r--r--src/nvim/version.c2
-rw-r--r--test/functional/legacy/assert_spec.lua18
3 files changed, 21 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ec53de3269..18d6dc1444 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7688,7 +7688,8 @@ static void f_assert_fails(typval_T *argvars, typval_T *rettv)
char_u buf[NUMBUFLEN];
char *error = (char *)get_tv_string_buf_chk(&argvars[1], buf);
- if (strstr((char *)vimvars[VV_ERRMSG].vv_str, error) == NULL) {
+ if (error == NULL
+ || strstr((char *)vimvars[VV_ERRMSG].vv_str, error) == NULL) {
prepare_assert_error(&ga);
fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
&vimvars[VV_ERRMSG].vv_tv);
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 7400385d2d..e66bf44846 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -119,7 +119,7 @@ static int included_patches[] = {
1570,
1569,
1568,
- // 1567,
+ 1567,
// 1566 NA
// 1565,
// 1564,
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua
index 1ce665360d..63699387c1 100644
--- a/test/functional/legacy/assert_spec.lua
+++ b/test/functional/legacy/assert_spec.lua
@@ -142,4 +142,22 @@ describe('assert function:', function()
})
end)
end)
+
+ -- assert_fails({cmd}, [, {error}])
+ describe('assert_fails', function()
+ it('should change v:errors when error does not match v:errmsg', function()
+ execute([[call assert_fails('xxx', {})]])
+ expected_errors({"Expected {} but got 'E731: using Dictionary as a String'"})
+ end)
+
+ it('should not change v:errors when cmd errors', function()
+ call('assert_fails', 'NonexistentCmd')
+ expected_empty()
+ end)
+
+ it('should change v:errors when cmd succeeds', function()
+ call('assert_fails', 'call empty("")')
+ expected_errors({'command did not fail: call empty("")'})
+ end)
+ end)
end)