cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How do I free the memory used by an in-memory, non-formdata post request? (HeapValidate exception)

From: Ola Mork <ola_at_agoragames.com>
Date: Mon, 11 Oct 2010 16:31:29 -0400

On Mon, Oct 11, 2010 at 3:15 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

>> What is the correct way to free _request.memory?
>
> That's your application's work.
>
>> Is it already free'd by curl and I don't need to worry about it?
>
> curl cannot free it, it doesn't even know what you allocated anything and it
> doesn't even know about _request.memory's existance.
>
>> I'd rather not call curl_global_cleanup after every single request.
>
> That wouldn't even solve anything.
>
>> I discovered this using libcurl 7.16.4 but it's apparent in 7.21.1 too.
>
> This is not a flaw in libcurl...

This is an application error, not a libcurl-confusion (as Mr. Stenberg
pointed out). I've attached a modified post-callback.c. The problem is
in incrementing the position of the pointer in the callback. To free
it, the pointer has to be moved back to its original location.

The sample does this:

pooh->readptr++

so to free it I have to do this:

pooh.readptr = pooh.readptr - strlen(data);
free(pooh.readptr);

Thanks for your help.

- Ola

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2010-10-11