From 1ffd20a26eeb360bc0d2fe8e36120d43134b465a Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 24 Sep 2021 22:42:31 +0100 Subject: [PATCH] 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. --- test/unit/eval/typval_spec.lua | 5 +++-- 1 file 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