From 5e1545204394996aa43be214bec688a4cfbaa78e Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 20 Aug 2022 17:24:28 +0100 Subject: [PATCH] fix(ui): don't allow decor provider with ns_id==0 Fixes #19831 --- src/nvim/decoration_provider.c | 1 + src/nvim/highlight.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/nvim/decoration_provider.c b/src/nvim/decoration_provider.c index 95e13b4240..14c1238fa4 100644 --- a/src/nvim/decoration_provider.c +++ b/src/nvim/decoration_provider.c @@ -174,6 +174,7 @@ void decor_providers_invoke_end(DecorProviders *providers, char **err) DecorProvider *get_decor_provider(NS ns_id, bool force) { + assert(ns_id > 0); size_t i; size_t len = kv_size(decor_providers); for (i = 0; i < len; i++) { diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index c26b00df79..d6a18fcf8e 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -174,6 +174,11 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault) { static int recursive = 0; + if (*ns_hl == 0) { + // ns=0 (the default namespace) does not have a provider so stop here + return -1; + } + if (*ns_hl < 0) { if (ns_hl_active <= 0) { return -1;