cURL / Mailing Lists / curl-users / Single Mail

curl-users

[ curl-Bugs-614246 ] memory leak in libcurl

From: <noreply_at_sourceforge.net>
Date: Wed, 25 Sep 2002 00:57:58 -0700

Bugs item #614246, was opened at 2002-09-25 00:57
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=614246&group_id=976

Category: libcurl
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: memory leak in libcurl

Initial Comment:
memory leak occurs when using libcurl 7.9.8 to get an URL (HTTP) by ranges.
What i want to do is to setup a curl instance and then get the URL by blocks
of data.
Hereafter a source code showing the problem.

/*******************************************************************************************/
/*******************************************************************************************/

/*********************************************************
 * initializations
 */

curl_handle=curl_easy_init();

curl_easy_setopt(curl_handle,CURLOPT_URL, the_url);

curl_easy_setopt(curl_handle,CURLOPT_CONNECTTIMEOUT,INTERNET_CONNECT_TIMEOUT/1000);

/*
 * range is a char * containing the range to get
 */
curl_easy_setopt(curl_handle,CURLOPT_RANGE,range);

curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS,1);

curl_easy_setopt(curl_handle,CURLOPT_MUTE,1);

curl_easy_setopt(curl_handle,CURLOPT_FILE, my_process);

/********************************************************
 * and then a loop more or less like this.
 * What is important is the fact i call CURLOPT_RANGE
 * again before any curl_easy_cleanup
 */

i=0;

while (i<2)
{
     res=curl_easy_perform(curl_handle);

     if(res==CURL_OK)
     {
        /*
         * this call causes a memory leak
         */
         curl_easy_setopt(curl_handle,CURLOPT_RANGE,new_range);

          /*
           * then i wait a little bit before requesting the next block of data
           */
         pthread_cond_timedwait( ......);
         i++;
     }
}

curl_easy_cleanup(curl_handle);

/*******************************************************************************************/
/*******************************************************************************************/

The memory leak occurs in http.c , Curl_http function about line 666.

conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", conn->range);

What i can propose is something like this :

if(conn->allocptr.rangeline) /* added */
{ /* added */
   free(conn->allocptr.rangeline); /* added */
} /* added */
conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", conn->range);

I tried this and no memory leak occured in libcurl.

Anyway, i am not sure it is a bug as maybe i am not using libcurl correctly ??

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=614246&group_id=976

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-09-25