commit 1ffd20a26eeb360bc0d2fe8e36120d43134b465a
parent 7f8c1e53a6c27ce6957b102d7b1c9ec808f61d60
Author: Sean Dewar <seandewar@users.noreply.github.com>
Date: Fri, 24 Sep 2021 22:42:31 +0100
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.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git 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