patch 9.1.1015: Coverity complains about dereferencing NULL value
Problem: Coverity complains about dereferencing NULL value
Solution: Check that cms2 is not null
closes: #16438
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/fold.c b/src/fold.c
index 3353cc5..64f9447 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1879,7 +1879,7 @@
{
// Also delete 'commentstring' if it matches.
cms2 = (char_u *)strstr((char *)cms, "%s");
- if (p - line >= cms2 - cms
+ if (cms2 != NULL && p - line >= cms2 - cms
&& STRNCMP(p - (cms2 - cms), cms, cms2 - cms) == 0
&& STRNCMP(p + len, cms2 + 2, STRLEN(cms2 + 2)) == 0)
{