aboutsummaryrefslogtreecommitdiff
path: root/lib/setopt.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-05-28 18:30:47 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-05-30 23:14:33 +0200
commitc4e6968127e876b01e5e0b4b7cdbc49d5267530c (patch)
tree7d74ba1d30f99ac91b050fbb6c5b44338c56e88f /lib/setopt.c
parent842f73de58f38bd6e285e08bbd1adb6c17cb62cd (diff)
url: alloc the download buffer at transfer start
... and free it as soon as the transfer is done. It removes the extra alloc when a new size is set with setopt() and reduces memory for unused easy handles. In addition: the closure_handle now doesn't use an allocated buffer at all but the smallest supported size as a stack based one. Closes #5472
Diffstat (limited to 'lib/setopt.c')
-rw-r--r--lib/setopt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/setopt.c b/lib/setopt.c
index 72704127c..2ddaeef7d 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -2076,7 +2076,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
arg = READBUFFER_MIN;
/* Resize if new size */
- if(arg != data->set.buffer_size) {
+ if((arg != data->set.buffer_size) && data->state.buffer) {
char *newbuff = realloc(data->state.buffer, arg + 1);
if(!newbuff) {
DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n"));