From a78eddd54112033eea0212865efd2f75cc59fc93 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 15 Jan 2025 12:05:00 +0800 Subject: vim-patch:9.1.1015: Coverity complains about dereferencing NULL value (#32020) Problem: Coverity complains about dereferencing NULL value Solution: Check that cms2 is not null closes: vim/vim#16438 https://github.com/vim/vim/commit/1ac53b84ada3a992f320566737e66fa00d48611f Co-authored-by: Christian Brabandt --- src/nvim/fold.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index c9699cb161..b59933d600 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1658,7 +1658,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char *marker, size_t marker if (*cms != NUL) { // Also delete 'commentstring' if it matches. char *cms2 = strstr(cms, "%s"); - if (p - line >= cms2 - cms + if (cms2 != NULL && p - line >= cms2 - cms && strncmp(p - (cms2 - cms), cms, (size_t)(cms2 - cms)) == 0 && strncmp(p + len, cms2 + 2, strlen(cms2 + 2)) == 0) { p -= cms2 - cms; -- cgit