Don't write to pmatch[nlimit:] when ncaps > nlimit, rc should not exceed nmatch
either as before r1897244.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@
1897248 13f79535-47bb-0310-9956-
ffa450edef68
if (rc >= 0) {
apr_size_t n = rc, i;
- if (rc == 0)
- rc = ncaps; /* All captured slots were filled in */
- else if (n > nmatch)
- n = nmatch;
+ if (n == 0 || n > nmatch)
+ rc = n = nmatch; /* All capture slots were filled in */
for (i = 0; i < n; i++) {
pmatch[i].rm_so = ovector[i * 2];
pmatch[i].rm_eo = ovector[i * 2 + 1];