curl-library
Re: What is the best way to debug this?
Date: Sun, 15 Jul 2012 17:04:09 +0400
On 07/15/2012 04:34 PM, Gisle Vanem wrote:
> "Igor Korot" <ikorot01_at_gmail.com> wrote:
>
>> Here is my code:
>>
>> [code]
>> struct curl_slist *post = NULL;
>> char *data;
>> sprintf( data, "---------------------------%x",
>> static_cast<unsigned int>( time( NULL ) ) );
>> post = curl_slist_append( post, "Content-Type: multipart/form-data" );
>> post = curl_slist_append( post, "Expect: 100-continue" );
>> post = curl_slist_append( post, "Connection: keep-alive" );
>> curl_easy_setopt( handle, CURLOPT_READFUNCTION, CWindowPanel::put_data );
>> curl_easy_setopt( handle, CURLOPT_READDATA, &data );
>
> You call sprintf() with a data pointer initialised where? 'data' points to
> a random location. Strange it doesn't crash. think you should do
> char data[100];
> snprintf (data, sizeof(data), "...");
>
> And be careful using C++ functions as callbacks.
>
Just to add, if all you want to do is post some data from a buffer to
server, you could just use CURLOPT_POSTFIELDS or CURLOPTCOPYPOSTFIELDS ,
without going for the callbacks. They are documented at
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html.
-lijo
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-07-15