0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.1025: checking NULL pointer after addition

Problem:    Checking NULL pointer after addition. (Coverity)
Solution:   First check for NULL, then add the column.
This commit is contained in:
Bram Moolenaar
2019-03-20 21:18:34 +01:00
parent 697005f2cf
commit 64c8ed366d
2 changed files with 5 additions and 2 deletions

View File

@@ -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. */