cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problem setting CURLOPT_WRITEDATA to NULL

From: Simon Elliott <simon_at_ctsn.co.uk>
Date: Fri, 23 Jul 2010 14:48:00 +0100

I get an error in curl_easy_perform() when I set the CURLOPT_WRITEDATA
option to NULL or zero on win32. I need to do this because I've previously
set it to data for a callback.

In debug mode this gives an assertion failure in sendf.c. In release mode
it just crashes. The problem doesn't happen if I comment out the
CURLOPT_WRITEDATA call.

I'm using Version 7.20.1 (14 April 2010).

Here's an example app which illustrates the problem:

#include "targetver.h"
#include <stdio.h>
#include <string>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

int main(void)
{
        CURL *curl;
        CURLcode res;
        curl_global_init(CURL_GLOBAL_DEFAULT);
        curl = curl_easy_init();
        if(curl)
        {
                curl_easy_setopt(curl, CURLOPT_URL, "ftp://xx.xx.xx.xx/xxxx/xxxxxxxx.xxx");
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, 0L);
                curl_easy_setopt(curl, CURLOPT_USERNAME, "xxxxxx");
                curl_easy_setopt(curl, CURLOPT_PASSWORD, "xxxxxx");
                curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0L);
                curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
                curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
                res = curl_easy_perform(curl);
                curl_easy_cleanup(curl);
                if(CURLE_OK != res)
                {
                        fprintf(stderr, "curl told us %d\n", res);
                }
        }
        curl_global_cleanup();
        return 0;
}

Thanks in advance for any thoughts on how to resolve this.

-- 
Simon Elliott
http://www.ctsn.co.uk
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-23