I've just begun studying libcurl and came across strange behavior of curl_easy_cleanup() function. The task of the program is primitive: to get html code from site and put it in stdout.
#include <cstdio>
#include <clocale>
#include "curl\curl.h"
int main()
{
setlocale(LC_ALL, ".utf8"); // deleting this doesn't help
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl_easy_init();
CURLcode res;
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, "https://cbr.ru/currency_base/daily/");
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
printf("Error\n");
}
}
curl_easy_cleanup(curl); // crash
curl_global_cleanup();
return 0;
}
All goes well, i have correct output, but curl_easy_cleanup throws access violation exception and program crashes. Why does it do this and how can I fix the problem? Thanks.
UPD: I use Visual Studio 2019 and compile as C++. I came to conclusion, that problem is that site uses https (not http). I tried several http sites and it worked well. How should I treat the https sites then?