diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-06 20:00:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-06 20:00:17 +0800 |
commit | ca5a810c4a67c9c3f482d0c015270c26aee2c943 (patch) | |
tree | a8f2de41d37f356fd075996a9bc439b6cf4946c3 /src/nvim/testing.c | |
parent | a67b76943a1e823e710be382f6e57fb0eff2c1a8 (diff) | |
download | rneovim-ca5a810c4a67c9c3f482d0c015270c26aee2c943.tar.gz rneovim-ca5a810c4a67c9c3f482d0c015270c26aee2c943.tar.bz2 rneovim-ca5a810c4a67c9c3f482d0c015270c26aee2c943.zip |
vim-patch:9.0.1511: crash when using wrong arg types to assert_match() (#23507)
Problem: Crash when using wrong arg types to assert_match().
Solution: Check for NULL pointer. (closes vim/vim#12349)
https://github.com/vim/vim/commit/12e7a1fe7527e9e59adbe248a95b4b532e3ec58c
Diffstat (limited to 'src/nvim/testing.c')
-rw-r--r-- | src/nvim/testing.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 430d6713ff..5483a58525 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -287,11 +287,10 @@ static int assert_match_common(typval_T *argvars, assert_type_T atype) { char buf1[NUMBUFLEN]; char buf2[NUMBUFLEN]; - const int called_emsg_before = called_emsg; const char *const pat = tv_get_string_buf_chk(&argvars[0], buf1); const char *const text = tv_get_string_buf_chk(&argvars[1], buf2); - if (called_emsg == called_emsg_before + if (pat != NULL && text != NULL && pattern_match(pat, text, false) != (atype == ASSERT_MATCH)) { garray_T ga; prepare_assert_error(&ga); @@ -393,12 +392,10 @@ static int assert_equalfile(typval_T *argvars) { char buf1[NUMBUFLEN]; char buf2[NUMBUFLEN]; - const int called_emsg_before = called_emsg; const char *const fname1 = tv_get_string_buf_chk(&argvars[0], buf1); const char *const fname2 = tv_get_string_buf_chk(&argvars[1], buf2); - garray_T ga; - if (called_emsg > called_emsg_before) { + if (fname1 == NULL || fname2 == NULL) { return 0; } @@ -451,7 +448,9 @@ static int 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) { char *const tofree = encode_tv2echo(&argvars[2], NULL); @@ -475,6 +474,7 @@ static int assert_equalfile(typval_T *argvars) ga_clear(&ga); return 1; } + return 0; } |