I want to thank those of you who discussed this issue with me.  The problem was 
in MemScope, in that it cannot properly account for re-allocation of memory.  
The presumed memory leak was a phantom.  Thank you for writing such a useful 
library, and thank you for your support through this email list.

Matt Fisher


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Lars Nilsson
Sent: Tuesday, February 22, 2011 2:21 PM
To: libcurl development
Subject: Re: Apparent memory leak deep in cURL library; requesting assistance

On Tue, Feb 22, 2011 at 1:46 PM, Fisher, Matt
<[email protected]> wrote:
> * The 20 byte buffer being leaked is allocated at line 1188 (using 7.21.3 
> code) of http.c - the one call to realloc() in Curl_add_buffer().
> * This same line 1188 is executed three times during a single 
> curlMlti_perform().  The first time, the calling sequence is Curl_do(line 
> 5336)->Curl_http(line 2537)->Curl_add_buffer(line 1188), and 20 bytes are 
> allocated - new_size is 20 - and this is the 20 bytes that is being leaked.
> * The second time line 1188 is executed the calling sequence is Curl_do(line 
> 5336)->Curl_http(line 2541)->Curl_add_bufferf(line 
> 1145)->Curl_add_buffer(line 188), new_size is 122, and this allocation is 
> properly freed.
> * The third time line 1188 is executed the calling sequence is again 
> Curl_do(line 5336)->Curl_http(line 2874)->Curl_add_buffer(line 1188), 
> new_size is 488, and again is properly freed.
>
> It is always that first 20 byte allocation that is getting leaked.

Maybe you could create a test program along the lines of

int main()
{
  char *new_rb = NULL;
  char *in_buffer = NULL;

  new_rb = malloc(20);
  in_buffer = new_rb;
  in_buffer = realloc(in_buffer, 122);
  in_buffer = realloc(in_buffer, 488);

  free(in_buffer);

  return EXIT_SUCCESS;
}

and see if MemScope detects any problems?

Lars Nilsson

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to