patch 8.1.2178: accessing uninitialized memory in test

Problem:    Accessing uninitialized memory in test.
Solution:   Check if there was a match before using the match position.
            (Dominique Pelle, closes #5088)
diff --git a/src/search.c b/src/search.c
index 91f53c6..ab0edc4 100644
--- a/src/search.c
+++ b/src/search.c
@@ -4877,7 +4877,7 @@
 	    regmatch.startpos[0].col++;
 	    nmatched = vim_regexec_multi(&regmatch, curwin, curbuf,
 			       pos.lnum, regmatch.startpos[0].col, NULL, NULL);
-	    if (!nmatched)
+	    if (nmatched != 0)
 		break;
 	} while (direction == FORWARD ? regmatch.startpos[0].col < pos.col
 				      : regmatch.startpos[0].col > pos.col);
@@ -4887,8 +4887,9 @@
 	    result = (nmatched != 0
 		&& regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
 		&& regmatch.startpos[0].col == regmatch.endpos[0].col);
-	    /* one char width */
-	    if (!result && inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col)
+	    // one char width
+	    if (!result && nmatched != 0
+			&& inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col)
 		result = TRUE;
 	}
     }
diff --git a/src/version.c b/src/version.c
index f96160e..6a58b3d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2178,
+/**/
     2177,
 /**/
     2176,