cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: UTF8_CONVERSION_ERROR_NEGATIVE failure

From: Lars Nilsson <chamaeleon_at_gmail.com>
Date: Mon, 21 Sep 2009 15:05:56 -0400

On Mon, Sep 21, 2009 at 2:46 PM, Gross, Tim (Utility Computing
Architect) <tim.gross_at_hp.com> wrote:
> Daniel,
> I think I have figured out the problem.  I do the following, prior to the curl_easy_perform() call:
>
>   char *temp_url = new char[100];
>   strcpy(temp_url, "http://myserver.com/whatever.cgi");
>   cURLres = curl_easy_setopt(m_curl, CURLOPT_URL, temp_url);
>   free(temp_url);
>
> From the documentation for curl_easy_setopt(), it appears that the third parameter (in my code temp_url) is copied and therefore it is safe to deallocate it after the call to curl_easy_setopt().  But this yields the failure that I described in my initial message.  It seems the problem is that the url is not valid when I invoke the curl_easy_perform() API.
>
> Furthermore, when I comment out the "free(temp_url)" statement, it is successful.  This is contrary to the documentation, but seems to be the fix.  Can you confirm this?

Do not use free() with new-allocated data, use delete. Do not use
delete with malloc-allocated data, use free().

And try to avoid top-posting. ;)

Lars Nilsson
Received on 2009-09-21