]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Save a few cycles.
authorChristophe Jaillet <jailletc36@apache.org>
Sun, 22 Apr 2018 19:36:41 +0000 (19:36 +0000)
committerChristophe Jaillet <jailletc36@apache.org>
Sun, 22 Apr 2018 19:36:41 +0000 (19:36 +0000)
We already know the length of the string we want to copy, so use 'apr_pstrmemdup()' instead of 'apr_strdup()'.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1829799 13f79535-47bb-0310-9956-ffa450edef68

server/util.c

index 5ec8f8e6e0edebc13bb3bff3e00fa1666d39fd4f..38ed346ce15e0cc5c56756888ff9dc7c395d5f1a 100644 (file)
@@ -2849,12 +2849,11 @@ AP_DECLARE(int) ap_parse_form_data(request_rec *r, ap_filter_t *f,
                     case FORM_NAME:
                         if (offset < HUGE_STRING_LEN) {
                             if ('=' == c) {
-                                buffer[offset] = 0;
-                                offset = 0;
                                 pair = (ap_form_pair_t *) apr_array_push(pairs);
-                                pair->name = apr_pstrdup(r->pool, buffer);
+                                pair->name = apr_pstrmemdup(r->pool, buffer, offset);
                                 pair->value = apr_brigade_create(r->pool, r->connection->bucket_alloc);
                                 state = FORM_VALUE;
+                                offset = 0;
                             }
                             else {
                                 buffer[offset++] = c;