diff --git a/src/nvim/message.c b/src/nvim/message.c index cf7922c978..46062fd8e6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -643,7 +643,7 @@ void reset_last_sourcing(void) /// @return true if "SOURCING_NAME" differs from "last_sourcing_name". static bool other_sourcing_name(void) { - if (SOURCING_NAME != NULL) { + if (HAVE_SOURCING_INFO && SOURCING_NAME != NULL) { if (last_sourcing_name != NULL) { return strcmp(SOURCING_NAME, last_sourcing_name) != 0; } @@ -659,7 +659,7 @@ static bool other_sourcing_name(void) static char *get_emsg_source(void) FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT { - if (SOURCING_NAME != NULL && other_sourcing_name()) { + if (HAVE_SOURCING_INFO && SOURCING_NAME != NULL && other_sourcing_name()) { char *sname = estack_sfile(ESTACK_NONE); char *tofree = sname; diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h index b3461a8743..43cdbd20dd 100644 --- a/src/nvim/runtime.h +++ b/src/nvim/runtime.h @@ -15,6 +15,7 @@ /// Stack of execution contexts. Each entry is an estack_T. /// Current context is at ga_len - 1. extern garray_T exestack; +#define HAVE_SOURCING_INFO (exestack.ga_data != NULL && exestack.ga_len > 0) /// name of error message source #define SOURCING_NAME (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_name) /// line number in the message source or zero