cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_cleanup modifies the stack???

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 31 Dec 2006 14:47:26 +0100 (CET)

On Fri, 29 Dec 2006, Braden McDaniel wrote:

> Can someone explain to me what's going on here? This code
>
> fprintf(stderr, "msg->easy_handle = %lu\n", ptrdiff_t(msg->easy_handle));
> curl_easy_cleanup(msg->easy_handle);
> fprintf(stderr, "msg->easy_handle = %lu\n", ptrdiff_t(msg->easy_handle));
>
> results in this output:
>
> msg->easy_handle = 10975264
> msg->easy_handle = 9801088

> Now, I know the docs for curl_easy_cleanup say that the handle isn't usable
> after calling the function. But even so, this outcome really surprised me. I
> just didn't expect a C function to behave this way.

You used curl_mult_info_read() to get that 'msg' pointer, and it will point to
memory that is kept in the CURL struct).

When you call curl_easy_cleanup(), libcurl will free the memory msg points to,
and thus you get this result. I'll clarify this somewhat better in the
curl_multi_info_read() man page.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-12-31