curl-library
Memory leak in curl_multi_perform
Date: Mon, 3 Jan 2011 15:08:20 +0530
Hi,
I am using libcurl 7.19.0 for my application. I understand this is very old
version, but I have been using this over a long period of development (over
1-1.5 years), and I cannot switch to the latest release because I am not
sure the latest libcurl might break my code and I will have to test all the
things all over again. So I am stuck to this version till I get some extra
time and do the upgradation.
Meanwhile I am in a fix right now. I am getting a memory leak from
multi_perform as follows:
==8728== 29 bytes in 1 blocks are definitely lost in loss record 110 of 237
==8728== at 0xFF785C4: malloc (vg_replace_malloc.c:236)
==8728== by 0x4195CF3: strdup (strdup.c:43)
==8728== by 0x10ABF7CB: readwrite_headers (transfer.c:1334)
==8728== by 0x10ABD6CF: readwrite_data (transfer.c:429)
==8728== by 0x10AC004F: Curl_readwrite (transfer.c:1600)
==8728== by 0x10A9729F: multi_runsingle (multi.c:1265)
==8728== by 0x10A978C3: curl_multi_perform (multi.c:1475)
==8728== by 0x10A4ECC7:
I have looked at the code in readwrite_headers (transfer.c:1334) and I found
the possible reason could be
following code from lib/transfer.c line
/* ignore empty data */
free(location);
else {
DEBUGASSERT(!data->req.location);
data->req.location = location;
if(data->set.http_follow_location) {
DEBUGASSERT(!data->req.newurl);
*data->req.newurl = strdup(data->req.location); */* clone */ //line 1334
Possible reason for memory leak
if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY;
I scanned the source files but could not find place where this
data->req.newurl is freed.
Then I took the latest version of libcurl curl-7.21.3
and in file lib/http.c I found data->req.newurl is freed in
Curl_http_auth_act line 470 and
Curl_proxyCONNECT line 1320
using free(data->req.newurl);
This code is not present in older version of libcurl.
Please let me know if the leak that I am getting is a real problem. And It
is solved by the newer version. so that In future I can switch to newer
version.
If it is not fixed, I request you to please look into this matter as this
could be a true leak. I dont have much understanding of libcurl code, so I
could not help much. I am sorry for that.
Can I add the code from latest version regarding free of data->req.newurl
and build the old libcurl with this patch so that I dont have to change
much. Will this leak be fixed if I do that??
Please guide.
Best Regards
Shivanand
-- -------------------- "It is only with the heart that one can see rightly; what is essential is invisible to the eye."
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-01-03