]> granicus.if.org Git - apache/commitdiff
avoid unnecessary memory operation
authorAndré Malo <nd@apache.org>
Thu, 24 Jul 2003 23:25:31 +0000 (23:25 +0000)
committerAndré Malo <nd@apache.org>
Thu, 24 Jul 2003 23:25:31 +0000 (23:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@100784 13f79535-47bb-0310-9956-ffa450edef68

modules/mappers/mod_rewrite.c

index 420ee1695e571043d7156de802f78f180d257971..4eedd5c1b844b511995bebdd2bc02d15bfe34e98 100644 (file)
@@ -1377,7 +1377,6 @@ static int hook_fixup(request_rec *r)
     char *cp;
     char *cp2;
     const char *ccp;
-    char *prefix;
     apr_size_t l;
     int rulestatus;
     int n;
@@ -1616,14 +1615,13 @@ static int hook_fixup(request_rec *r)
                  * document_root if it is prefix
                  */
                 if ((ccp = ap_document_root(r)) != NULL) {
-                    prefix = apr_pstrdup(r->pool, ccp);
-                    /* always NOT have a trailing slash */
-                    l = strlen(prefix);
-                    if (prefix[l-1] == '/') {
-                        prefix[l-1] = '\0';
-                        l--;
+                    /* strip trailing slash */
+                    l = strlen(ccp);
+                    if (ccp[l-1] == '/') {
+                        --l;
                     }
-                    if (strncmp(r->filename, prefix, l) == 0) {
+                    if (!strncmp(r->filename, ccp, l) &&
+                        r->filename[l] == '/') {
                         rewritelog(r, 2,
                                    "[per-dir %s] strip document_root "
                                    "prefix: %s -> %s",