You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2021/11/12 18:14:04 UTC
svn commit: r1894983 - /httpd/apreq/trunk/library/parser_multipart.c
Author: ylavic
Date: Fri Nov 12 18:14:04 2021
New Revision: 1894983
URL: http://svn.apache.org/viewvc?rev=1894983&view=rev
Log:
create_multipart_context: Save some allocation space.
Modified:
httpd/apreq/trunk/library/parser_multipart.c
Modified: httpd/apreq/trunk/library/parser_multipart.c
URL: http://svn.apache.org/viewvc/httpd/apreq/trunk/library/parser_multipart.c?rev=1894983&r1=1894982&r2=1894983&view=diff
==============================================================================
--- httpd/apreq/trunk/library/parser_multipart.c (original)
+++ httpd/apreq/trunk/library/parser_multipart.c Fri Nov 12 18:14:04 2021
@@ -220,17 +220,24 @@ struct mfd_ctx * create_multipart_contex
{
apr_status_t s;
apr_size_t blen;
- struct mfd_ctx *ctx = apr_palloc(pool, sizeof *ctx);
- char *ct = apr_pstrdup(pool, content_type);
+ struct mfd_ctx *ctx;
+ const char *attr;
+ char *buf;
- ct = strchr(ct, ';');
- if (ct == NULL)
+ attr = (content_type) ? strchr(content_type, ';') : NULL;
+ if (!attr)
return NULL; /* missing semicolon */
- *ct++ = 0;
- s = apreq_header_attribute(ct, "boundary", 8,
- (const char **)&ctx->bdry, &blen);
+ ctx = apr_palloc(pool, sizeof *ctx);
+
+ attr++;
+ blen = strlen(attr) + 1;
+ buf = apr_palloc(pool, 4 + blen);
+ buf += 4;
+ memcpy(buf, attr, blen);
+ s = apreq_header_attribute(buf, "boundary", 8,
+ (const char **)&ctx->bdry, &blen);
if (s != APR_SUCCESS)
return NULL; /* missing boundary */