cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] fix memory leak in lib/easy

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Thu, 5 Mar 2009 10:15:53 +0100

Hi Dan,

thanks for your quick response!

On Thursday 05 March 2009 05:08:16 Dan Fandrich wrote:
> curl_global_init() must be called by curl_easy_init() (if it wasn't
> already), but curl_global_cleanup must not be called by curl_easy_cleanup()
> under any circumstances. There could be many easy handles still active at
> the time curl_easy_cleanup() is called and calling curl_global_cleanup
> would close them all. curl_global_cleanup must only be called when the app
> has completely finished all use of libcurl, and there's no other way for
> libcurl itself to know when that has happened, even when all easy handled
> have themselves been closed.

Please look at the begin of curl_global_init() function. There is a counter.
It is safe to call it when already initialized - the only thing happens
is the incrementation of the counter. And then curl_easy_cleanup() just
decrement this counter. There is no action performed if counter value
is non-zero.

Can you give a simple example of lib/easy usage, when this patch does not work
properly? In this case do we have another solution to free resources?

Kamil
Received on 2009-03-05