cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_pause bugs

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 4 Sep 2008 15:26:51 -0700

On Thu, Sep 04, 2008 at 09:48:13AM +0200, Daniel Stenberg wrote:
> Right, so I figure this approach is more like it:

Looks good to me. Here's a corresponding (untested) patch to use realloc for
the pause buffer in Curl_client_write as well:

--- lib/sendf.c 4 Sep 2008 19:43:37 -0000 1.144
+++ lib/sendf.c 4 Sep 2008 22:19:43 -0000
@@ -451,19 +451,16 @@
     if(type != data->state.tempwritetype)
       /* 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;

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-09-05