regex: simplify op_count_full error check master
authorMarko Kreen <[email protected]>
Tue, 30 Dec 2014 13:18:52 +0000 (15:18 +0200)
committerMarko Kreen <[email protected]>
Tue, 30 Dec 2014 13:18:52 +0000 (15:18 +0200)
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
usual/regex.c

index 28fbca7084c54f84be72e7068f91022846279853..a500fbb37f5df3df39cbbe0d0019e1bd436e442e 100644 (file)
@@ -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;