From 9f84e01dfb0d9bb0eff1a5c709a6c1158be1e131 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 Oct 2025 21:20:36 -0400 Subject: [PATCH] vim-patch:8.2.3673: crash when allocating signal stack fails Problem: Crash when allocating signal stack fails. Solution: Only using sourcing info when available. (closes vim/vim#9215) https://github.com/vim/vim/commit/0bd8d0563853ab821a018fb9cdd85f674684fe57 Co-authored-by: Bram Moolenaar --- src/nvim/message.c | 4 ++-- src/nvim/runtime.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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