cURL / Mailing Lists / curl-library / Single Mail

curl-library

Unhandled exception in VC++ 2010 with curl_easy

From: William Elliott <elkhartrx7_at_mail.com>
Date: Tue, 15 Sep 2015 19:15:25 +0200

I'm using VC++ 2010 and I'm getting this error:

An unhandled exception of type 'System.AccessViolationException' occurred in Fourth.exe Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

on the line:

res = curl_easy_perform(curl);

Any ideas where i am going wrong?

 

std::string DownloadFile(std::string Fname, std::string Furl)
{
            CURL *curl;
            CURLcode res;
            const char *url = Furl.c_str();
            curl = curl_easy_init();
            if (curl) {
                FILE * pFile;
                pFile = fopen(Fname.c_str(),"wb");
                if (pFile!=NULL) {
                    curl_easy_setopt(curl, CURLOPT_URL, url);
                    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
                    curl_easy_setopt(curl, CURLOPT_WRITEDATA, pFile);
                    curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
                    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);
                    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
                    char errbuf[CURL_ERROR_SIZE];
                    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
                    res = curl_easy_perform(curl);
                    std::string xres = curl_easy_strerror(res);
                    curl_easy_cleanup(curl);
                    fclose(pFile);
                    return xres;
                }
            }
}

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-09-15