- n = ngx_regex_exec(sn[i].regex, &name, NULL, 0);
+ if (sn[i].captures && r->captures == NULL) {
+
+ ncaptures = (NGX_HTTP_MAX_CAPTURES + 1) * 3 * sizeof(int);
+
+ r->captures = ngx_palloc(r->pool, ncaptures);
+ if (r->captures == NULL) {
+ return NGX_ERROR;
+ }
+
+ if (server == buf) {
+ server = ngx_pnalloc(r->pool, len);
+ if (server == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_memcpy(server, buf, len);
+ name.data = server;
+ }
+ }
+
+ n = ngx_regex_exec(sn[i].regex, &name, r->captures, ncaptures);