Hi,

I am trying to figure out why I am getting segfaults in my code.

Here is the c-code:

#include <curl/curl.h>

int main(void)
{
char *url="https://www.knebb.de/files/text.txt";;
char *filename="/tmp/wetter.test";
CURL *curl_handle;
FILE *FI;
int r;

r=0;
/* init the curl session and set url*/
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
FI = fopen(filename, "w");
if(FI) {
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, FI);
    r = curl_easy_perform(curl_handle);
}
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
r = fclose(FI);
printf("Fertig: %d\n",r);
}


I compile it with
gcc -o Beispiel beispiel.c -lcurl

Starting it I am getting a segfault. As soon as I remove the curl_easy_cleanup() call it runs fine.

System is running on a Raspberry with Debian:
libcurl 7.64.0-4+deb10u9

Any ideas what I did wrong?

Thanks!

/KNEBB
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to