]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
nmatch may be NULL, too. Closes #868
authorAlan T. DeKok <aland@freeradius.org>
Sat, 3 Jan 2015 01:22:35 +0000 (20:22 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 3 Jan 2015 01:22:35 +0000 (20:22 -0500)
src/lib/regex.c

index a11c49d37b03ed4e62ab47be89488a1d2254f92a..232af70098b58333973767a94014638fef939cac 100644 (file)
@@ -152,10 +152,17 @@ int regex_exec(regex_t *preg, char const *subject, size_t len, regmatch_t pmatch
        if (!pmatch || !nmatch) {
                pmatch = NULL;
                if (nmatch) *nmatch = 0;
+               nmatch = NULL;
                matches = 0;
                eflags |= PCRE_NO_AUTO_CAPTURE;
-       } else {
+
+       } else if (nmatch) {
                matches = *nmatch;
+
+       } else {
+               eflags |= PCRE_NO_AUTO_CAPTURE;
+               pmatch = NULL;
+               matches = 0;
        }
 
        ret = pcre_exec(preg->compiled, preg->extra, subject, len, 0, eflags, (int *)pmatch, matches * 3);