summaryrefslogtreecommitdiffstats
path: root/src/regexp.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-03-20 21:18:34 +0100
committerBram Moolenaar <Bram@vim.org>2019-03-20 21:18:34 +0100
commit64c8ed366de995a01ca1a072a6943ede0d7bb932 (patch)
treed39c1a936af2e2e4fc2e296fd7e179276e2a661e /src/regexp.c
parent697005f2cf0b41b22a673a67401a2c4d974e72d4 (diff)
patch 8.1.1025: checking NULL pointer after additionv8.1.1025
Problem: Checking NULL pointer after addition. (Coverity) Solution: First check for NULL, then add the column.
Diffstat (limited to 'src/regexp.c')
-rw-r--r--src/regexp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/regexp.c b/src/regexp.c
index 4b853172e5..5557987d58 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -7784,9 +7784,10 @@ reg_submatch(int no)
if (lnum < 0 || rsm.sm_mmatch->endpos[no].lnum < 0)
return NULL;
- s = reg_getline_submatch(lnum) + rsm.sm_mmatch->startpos[no].col;
- if (s == NULL) /* anti-crash check, cannot happen? */
+ s = reg_getline_submatch(lnum);
+ if (s == NULL) // anti-crash check, cannot happen?
break;
+ s += rsm.sm_mmatch->startpos[no].col;
if (rsm.sm_mmatch->endpos[no].lnum == lnum)
{
/* Within one line: take form start to end col. */