From: Marko Kreen <markokr@gmail.com>
Date: Tue, 30 Dec 2014 13:18:52 +0000 (+0200)
Subject: regex: simplify op_count_full error check
X-Git-Url: http://git.postgresql.org/gitweb/static/formdemo.sql?a=commitdiff_plain;p=libusual.git

regex: simplify op_count_full error check

There was dummy loop with size limit for "performace" reasons,
but it triggered automatic checkers.  Remove complexity
by using strchr() there.

Reported-By: David Binderman
---

diff --git a/usual/regex.c b/usual/regex.c
index 28fbca7..a500fbb 100644
--- a/usual/regex.c
+++ b/usual/regex.c
@@ -315,11 +315,7 @@ static int op_count_full(struct ParseCtx *ctx, const char **re)
 	}
 
 	/* bad fmt, decide between error codes */
-	for (a = 0; end[a] && a < 5; a++) {
-		if (end[a] == '}')
-			return REG_BADBR;
-	}
-	return REG_EBRACE;
+	return strchr(end, '}') ? REG_BADBR : REG_EBRACE;
 
 done:
 	ctx->last_elem->mincnt = a;
