cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Apparent memory leak deep in cURL library; requesting assistance

From: Lars Nilsson <chamaeleon_at_gmail.com>
Date: Tue, 22 Feb 2011 14:21:20 -0500

On Tue, Feb 22, 2011 at 1:46 PM, Fisher, Matt
<Matthew.Fisher_at_tekelec.com> 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
Received on 2011-02-22