cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 7 Mar 2009 22:33:53 +0100 (CET)

On Sat, 7 Mar 2009, Kamil Dudka wrote:

> The value of 'initialized' is dependent on the order of call
> curl_global_init/curl_easy_init from the application. The information about
> this order is lost.

The order is not important. By the API docs you SHOULD call curl_global_init()
first and curl_global_cleanup last. If you don't, libcurl does its best to
survive anyway and in my view it does that fairly well.

If you then choose not to adhere to the API, you risk a "leak" like this yes.

> Well, it works fine if you call curl_global_init and then curl_easy_init.
> But look at src/main.c - this is not the case.

A) that is not libcurl code.

B) I consider that a bug in the curl tool's code and we should fix it there

> Then it never becomes zero and there is no cleanup. That's not what we need,
> is it?

It's tough to depend on the counter that is counted up and down from within
the curl_easy_init() and curl_easy_cleanup() since they may be called
multi-threaded and the counter may thus not reach zero anyhow.

-- 
  / daniel.haxx.se
Received on 2009-03-07