Browse code

regex: quiet findmust() warnings #10615 & #10616, added some safety for bad cases

David Raynor authored on 2013/08/08 05:36:11
Showing 1 changed files
... ...
@@ -1414,8 +1414,8 @@ static void
1414 1414
 findmust(struct parse *p, struct re_guts *g)
1415 1415
 {
1416 1416
 	sop *scan;
1417
-	sop *start;    /* start initialized in the default case, after that */
1418
-	sop *newstart; /* newstart was initialized in the OCHAR case */
1417
+	sop *start = NULL;    /* start initialized in the default case, after that */
1418
+	sop *newstart = NULL; /* newstart was initialized in the OCHAR case */
1419 1419
 	sopno newlen;
1420 1420
 	sop s;
1421 1421
 	char *cp;
... ...
@@ -1466,6 +1466,10 @@ findmust(struct parse *p, struct re_guts *g)
1466 1466
 
1467 1467
 	if (g->mlen == 0)		/* there isn't one */
1468 1468
 		return;
1469
+	if (start == NULL) {		/* something went wrong */
1470
+		g->mlen = 0;
1471
+		return;
1472
+	}
1469 1473
 
1470 1474
 	/* turn it into a character string */
1471 1475
 	g->must = cli_malloc((size_t)g->mlen + 1);