- if ((req->q.sec = strrchr(req->q.query, '.')) != NULL) {
- if(isdigit((unsigned char)req->q.sec[1])) {
- *req->q.sec++ = '\0';
- req->q.sec = mandoc_strdup(req->q.sec);
- } else
- req->q.sec = NULL;
+ sec = strrchr(name, '.');
+ if (sec != NULL && isdigit((unsigned char)*++sec)) {
+ req->q.query = mandoc_strndup(name, sec - name - 1);
+ req->q.sec = mandoc_strdup(sec);
+ } else {
+ req->q.query = mandoc_strdup(name);
+ req->q.sec = NULL;