aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-07-04 17:28:33 +0300
committerZyX <kp-pav@yandex.ru>2017-07-04 18:37:01 +0300
commitf81d1ce003010892859898ec0436f81a883d4f3c (patch)
tree9b8ab85ca1ae2aeb996ca00bc00c3bba23c1812f /src
parent6552768c4faa1fcc81be49859815966123476e04 (diff)
downloadrneovim-f81d1ce003010892859898ec0436f81a883d4f3c.tar.gz
rneovim-f81d1ce003010892859898ec0436f81a883d4f3c.tar.bz2
rneovim-f81d1ce003010892859898ec0436f81a883d4f3c.zip
regexp: Silence V595: potential null dereference
The code uses 2-iteration loop antipattern: retval is NULL on first iteration, not NULL on second, yet this is still a false positive.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/regexp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 5448cc7131..41070aebf4 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -6928,9 +6928,10 @@ char_u *reg_submatch(int no)
STRNCPY(retval + len, reg_getline_submatch(lnum),
submatch_mmatch->endpos[no].col);
len += submatch_mmatch->endpos[no].col;
- if (round == 2)
- retval[len] = NUL;
- ++len;
+ if (round == 2) {
+ retval[len] = NUL; // -V595
+ }
+ len++;
}
if (retval == NULL) {