cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: WRITEFUNCTION crashes

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 23 Jan 2013 19:47:12 +0100 (CET)

On Tue, 22 Jan 2013, Khaled El Manawhly wrote:

> OK I simplified the code a bit, unfortunately I still get a crash, with NULL
> values being passed to the callback function. (I realise I omitted the call
> to the writefunction in the above example, but it WAS in my code.)
>
> size_t callback_func(char *ptr, size_t size, size_t count, void *stream)
> {
> printf("Entered callback\n");
>
> size_t realsize = size * count;
>
> return realsize;
> }
>
>
> void SSHConnect(char *hostname,char *user,char *pass)
> {
> char strBuffer[1024];
> sprintf(strBuffer,"sftp://%s:%s@%s",user,pass,hostname);
> curl_easy_setopt(hCurl, CURLOPT_URL, strBuffer);
>
> curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, &callback_func);
>
> int chunk;
>
> curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void *)&chunk);
>
> curl_easy_perform(hCurl);
> }

If this program crashes, then I recommend using valgrind to pinpoint exactly
where and why....

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-01-23