aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-09-05 09:37:37 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-09-05 09:37:37 +0000
commit873e734c3971fd620c09bdc31c2e7e4cfc4a0a67 (patch)
treee2ffbff3fe41423a3f9c2c3acda7d8346a896cf1 /lib
parent747e0c657dab3fee32b6db6035cfdc33e485aa9b (diff)
- Dmitriy Sergeyev pointed out that curl_easy_pause() didn't unpause properly
during certain conditions. I also changed this code to use realloc() based on Daniel Fandrich's suggestion.
Diffstat (limited to 'lib')
-rw-r--r--lib/easy.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/easy.c b/lib/easy.c
index d83a88511..741dbb217 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -821,6 +821,7 @@ CURLcode curl_easy_pause(CURL *curl, int action)
return PAUSE again and then we'll get a new copy allocted and stored in
the tempwrite variables */
char *tempwrite = data->state.tempwrite;
+ char *freewrite = tempwrite; /* store this pointer to free it later */
size_t tempsize = data->state.tempwritesize;
int temptype = data->state.tempwritetype;
size_t chunklen;
@@ -845,7 +846,7 @@ CURLcode curl_easy_pause(CURL *curl, int action)
result = Curl_client_write(data->state.current_conn,
temptype, tempwrite, chunklen);
- if(!result)
+ if(result)
/* failures abort the loop at once */
break;
@@ -858,13 +859,13 @@ CURLcode curl_easy_pause(CURL *curl, int action)
*/
char *newptr;
- free(data->state.tempwrite); /* free the one just cached as it isn't
- enough */
-
/* note that tempsize is still the size as before the callback was
used, and thus the whole piece of data to keep */
- newptr = malloc(tempsize);
+ newptr = realloc(data->state.tempwrite, tempsize);
+
if(!newptr) {
+ free(data->state.tempwrite); /* free old area */
+ data->state.tempwrite = NULL;
result = CURLE_OUT_OF_MEMORY;
/* tempwrite will be freed further down */
break;
@@ -882,7 +883,7 @@ CURLcode curl_easy_pause(CURL *curl, int action)
} while((result == CURLE_OK) && tempsize);
- free(tempwrite); /* this is unconditionally no longer used */
+ free(freewrite); /* this is unconditionally no longer used */
}
return result;