diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-09-24 22:42:31 +0100 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-06-12 13:27:16 +0800 |
commit | 1ffd20a26eeb360bc0d2fe8e36120d43134b465a (patch) | |
tree | fa7eda809261ff7f350804a24eaac2ef25cf7fb0 | |
parent | 7f8c1e53a6c27ce6957b102d7b1c9ec808f61d60 (diff) | |
download | rneovim-1ffd20a26eeb360bc0d2fe8e36120d43134b465a.tar.gz rneovim-1ffd20a26eeb360bc0d2fe8e36120d43134b465a.tar.bz2 rneovim-1ffd20a26eeb360bc0d2fe8e36120d43134b465a.zip |
test(unit/eval/typval_spec): don't dereference NULL last_msg_hist
If last_msg_hist is NULL, check_emsg will cause the running test process
to SIGSEGV from trying to access the msg member.
-rw-r--r-- | test/unit/eval/typval_spec.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/test/unit/eval/typval_spec.lua b/test/unit/eval/typval_spec.lua index cde5a731cf..5e8677c69d 100644 --- a/test/unit/eval/typval_spec.lua +++ b/test/unit/eval/typval_spec.lua @@ -101,12 +101,13 @@ local function check_emsg(f, msg) saved_last_msg_hist = nil end local ret = {f()} + local last_msg = lib.last_msg_hist ~= nil and ffi.string(lib.last_msg_hist.msg) or nil if msg ~= nil then - eq(msg, ffi.string(lib.last_msg_hist.msg)) + eq(msg, last_msg) neq(saved_last_msg_hist, lib.last_msg_hist) else if saved_last_msg_hist ~= lib.last_msg_hist then - eq(nil, ffi.string(lib.last_msg_hist.msg)) + eq(nil, last_msg) else eq(saved_last_msg_hist, lib.last_msg_hist) end |