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>
This commit is contained in:
Christian Brabandt
2025-01-14 17:25:02 +01:00
parent 57f0119358
commit 1ac53b84ad
2 changed files with 3 additions and 1 deletions

View File

@ -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)
{

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1015,
/**/
1014,
/**/