summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_assert.vim17
-rw-r--r--src/testing.c22
-rw-r--r--src/version.c2
3 files changed, 30 insertions, 11 deletions
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index b7530bf1b9..d143f19f59 100644
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -335,6 +335,23 @@ func Test_assert_fail_fails()
call remove(v:errors, 0)
endfunc
+func Test_assert_wrong_arg_emsg_off()
+ CheckFeature folding
+
+ new
+ call setline(1, ['foo', 'bar'])
+ 1,2fold
+
+ " This used to crash Vim
+ let &l:foldtext = 'assert_match({}, {})'
+ redraw!
+
+ let &l:foldtext = 'assert_equalfile({}, {})'
+ redraw!
+
+ bwipe!
+endfunc
+
func Test_assert_fails_in_try_block()
try
call assert_equal(0, assert_fails('throw "error"'))
diff --git a/src/testing.c b/src/testing.c
index 0954814774..dfa9c606a0 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -281,9 +281,6 @@ assert_match_common(typval_T *argvars, assert_type_T atype)
garray_T ga;
char_u buf1[NUMBUFLEN];
char_u buf2[NUMBUFLEN];
- int called_emsg_before = called_emsg;
- char_u *pat;
- char_u *text;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
@@ -291,9 +288,9 @@ assert_match_common(typval_T *argvars, assert_type_T atype)
|| check_for_opt_string_arg(argvars, 2) == FAIL))
return 1;
- pat = tv_get_string_buf_chk(&argvars[0], buf1);
- text = tv_get_string_buf_chk(&argvars[1], buf2);
- if (called_emsg == called_emsg_before
+ char_u *pat = tv_get_string_buf_chk(&argvars[0], buf1);
+ char_u *text = tv_get_string_buf_chk(&argvars[1], buf2);
+ if (pat != NULL && text != NULL
&& pattern_match(pat, text, FALSE) != (atype == ASSERT_MATCH))
{
prepare_assert_error(&ga);
@@ -420,24 +417,23 @@ assert_equalfile(typval_T *argvars)
{
char_u buf1[NUMBUFLEN];
char_u buf2[NUMBUFLEN];
- int called_emsg_before = called_emsg;
char_u *fname1 = tv_get_string_buf_chk(&argvars[0], buf1);
char_u *fname2 = tv_get_string_buf_chk(&argvars[1], buf2);
- garray_T ga;
FILE *fd1;
FILE *fd2;
char line1[200];
char line2[200];
int lineidx = 0;
- if (called_emsg > called_emsg_before)
+ if (fname1 == NULL || fname2 == NULL)
return 0;
IObuff[0] = NUL;
fd1 = mch_fopen((char *)fname1, READBIN);
if (fd1 == NULL)
{
- vim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str, fname1);
+ vim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str,
+ fname1);
}
else
{
@@ -445,7 +441,8 @@ assert_equalfile(typval_T *argvars)
if (fd2 == NULL)
{
fclose(fd1);
- vim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str, fname2);
+ vim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str,
+ fname2);
}
else
{
@@ -498,8 +495,10 @@ assert_equalfile(typval_T *argvars)
fclose(fd2);
}
}
+
if (IObuff[0] != NUL)
{
+ garray_T ga;
prepare_assert_error(&ga);
if (argvars[2].v_type != VAR_UNKNOWN)
{
@@ -528,6 +527,7 @@ assert_equalfile(typval_T *argvars)
ga_clear(&ga);
return 1;
}
+
return 0;
}
diff --git a/src/version.c b/src/version.c
index 5253c49aec..9f4a449340 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1511,
+/**/
1510,
/**/
1509,