aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2008-09-05 17:21:54 +0000
committerDan Fandrich <dan@coneharvesters.com>2008-09-05 17:21:54 +0000
commit3acd1146f992a2b8c5da22a425c1380673c5bdef (patch)
tree077562b05c6c52d9b6034529c933ea1bbf959723 /lib
parent45d3bfff287ad212410156c008a57a166a8646f8 (diff)
Use realloc when paused in Curl_client_write
Diffstat (limited to 'lib')
-rw-r--r--lib/sendf.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/sendf.c b/lib/sendf.c
index 9a1c157c0..cdab3abdd 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -452,18 +452,16 @@ CURLcode Curl_client_write(struct connectdata *conn,
/* major internal confusion */
return CURLE_RECV_ERROR;
+ DEBUGASSERT(data->state.tempwrite);
+
/* figure out the new size of the data to save */
newlen = len + data->state.tempwritesize;
/* allocate the new memory area */
- newptr = malloc(newlen);
+ newptr = realloc(data->state.tempwrite, newlen);
if(!newptr)
return CURLE_OUT_OF_MEMORY;
- /* copy the previously held data to the new area */
- memcpy(newptr, data->state.tempwrite, data->state.tempwritesize);
/* copy the new data to the end of the new area */
memcpy(newptr + data->state.tempwritesize, ptr, len);
- /* free the old data */
- free(data->state.tempwrite);
/* update the pointer and the size */
data->state.tempwrite = newptr;
data->state.tempwritesize = newlen;