summaryrefslogtreecommitdiff
path: root/lib/mime.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-02-12 14:30:25 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-02-12 22:55:32 +0100
commit179927c12a54ea810bbc7c6c6fb970ad90b89eef (patch)
tree5cf9b6a9f36beae7b893e0d4b10c38bdda7830ac /lib/mime.c
parent84c10dc1ba683a2c15303ad3909e30a5a115a282 (diff)
downloadcurl-179927c12a54ea810bbc7c6c6fb970ad90b89eef.tar.gz
mime: put the boundary buffer into the curl_mime struct
... instead of allocating it separately and point to it. It is fixed-size and always used for each part. Closes #3561
Diffstat (limited to 'lib/mime.c')
-rw-r--r--lib/mime.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/mime.c b/lib/mime.c
index ca492d11a..48147d4f5 100644
--- a/lib/mime.c
+++ b/lib/mime.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -1122,8 +1122,6 @@ void curl_mime_free(curl_mime *mime)
Curl_mime_cleanpart(part);
free(part);
}
-
- free(mime->boundary);
free(mime);
}
}
@@ -1220,18 +1218,10 @@ curl_mime *curl_mime_init(struct Curl_easy *easy)
mime->firstpart = NULL;
mime->lastpart = NULL;
- /* Get a part boundary. */
- mime->boundary = malloc(24 + MIME_RAND_BOUNDARY_CHARS + 1);
- if(!mime->boundary) {
- free(mime);
- return NULL;
- }
-
memset(mime->boundary, '-', 24);
- if(Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24,
+ if(Curl_rand_hex(easy, (unsigned char *) &mime->boundary[24],
MIME_RAND_BOUNDARY_CHARS + 1)) {
/* failed to get random separator, bail out */
- free(mime->boundary);
free(mime);
return NULL;
}