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

1ac53b84ad

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq 2025-01-15 12:05:00 +08:00 committed by GitHub
parent 611ef35491
commit a78eddd541
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1658,7 +1658,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char *marker, size_t marker
if (*cms != NUL) { if (*cms != NUL) {
// Also delete 'commentstring' if it matches. // Also delete 'commentstring' if it matches.
char *cms2 = strstr(cms, "%s"); 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 - (cms2 - cms), cms, (size_t)(cms2 - cms)) == 0
&& strncmp(p + len, cms2 + 2, strlen(cms2 + 2)) == 0) { && strncmp(p + len, cms2 + 2, strlen(cms2 + 2)) == 0) {
p -= cms2 - cms; p -= cms2 - cms;