Commit: patch 9.1.1015: Coverity complains about dereferencing NULL value

5 views
Skip to first unread message

Christian Brabandt

unread,
Jan 14, 2025, 11:30:21 AM1/14/25
to vim...@googlegroups.com
patch 9.1.1015: Coverity complains about dereferencing NULL value

Commit: https://github.com/vim/vim/commit/1ac53b84ada3a992f320566737e66fa00d48611f
Author: Christian Brabandt <c...@256bit.org>
Date: Tue Jan 14 17:25:02 2025 +0100

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 <c...@256bit.org>

diff --git a/src/fold.c b/src/fold.c
index 3353cc55f..64f9447b7 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1879,7 +1879,7 @@ foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
{
// 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)
{
diff --git a/src/version.c b/src/version.c
index 57d7ec7d4..96a51da80 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1015,
/**/
1014,
/**/
Reply all
Reply to author
Forward
0 new messages